title: Digit restriction on SQL server numeric field
body: <p>How can i restrict field in a table to 15 or 16 digits. I have this table:</p>
  
  <pre><code>create table Person(    
      ,UserID varchar(30)
      ,Password varchar(30) not null
      ,CCtype varchar(8)
      ,CCNumber numeric
      ,primary key(UserID)
      ,constraint CK_CCvalidity check 
          (
              (CCType is null or CCNumber is null) 
              or 
              (
                  (CCType = 'Amex' or CCType = 'Discover' or CCType = 'MC' or CCType = 'VISA')
                  and
                  (CCNumber &gt;= 15 and CCNumber &lt;= 16)
              )
          )   
  );
  </code></pre>
  
  <p>But this actually checks for the values 15 an 16, not for the number of digits. Also, we can assume that the numeric may hold 000... as the first digits. </p>
  
  <p>Thanks for the help</p>