Check constraint  
Author Message
mlegg10





PostPosted: Tue Oct 07 16:44:01 CDT 2003 Top

SQL Server Developer >> Check constraint

What check constraint could you use to make sure only a
number (of variable length) is entered into a varchar
column?

SQL Server162  
 
 
Vern





PostPosted: Tue Oct 07 16:44:01 CDT 2003 Top

SQL Server Developer >> Check constraint ISNUMERIC(ColumnName) = 1

HTH
Vern

>-----Original Message-----
>What check constraint could you use to make sure only a
>number (of variable length) is entered into a varchar
>column?
>.
>
 
 
Peter





PostPosted: Tue Oct 07 17:00:29 CDT 2003 Top

SQL Server Developer >> Check constraint Thanks for your quick response!
>-----Original Message-----
>ISNUMERIC(ColumnName) = 1
>
>HTH
>Vern
>
>>-----Original Message-----
>>What check constraint could you use to make sure only a
>>number (of variable length) is entered into a varchar
>>column?
>>.
>>
>.
>
 
 
Steve





PostPosted: Tue Oct 07 17:47:10 CDT 2003 Top

SQL Server Developer >> Check constraint Peter,

If by "a number", you mean an integer with no decimal
point and no - sign, you can filter more out than what
ISNUMERIC will find by

CHECK (Mycolumn not like '%[^0-9]%')

You may want to check for '' as well.

-- Steve Kass
-- Drew University
-- Ref: B7DFD42D-CB02-4846-A50A-227F6ED6C06C


> What check constraint could you use to make sure only a
> number (of variable length) is entered into a varchar
> column?