Numeric only char or varchar
Posted in 2000
Topics: Data Types & Schema Design
Hi, I want to make a varchar field that only allows numeric characters. I have tried this: tbl_ssn VARCHAR(10) CHECK (tbl_ssn MATCHES '[0-9]') but that allows only 1 character so I tried tbl_ssn VARCHAR(10) CHECK (tbl_ssn MATCHES '[0-9]*') but that only checks the first character of the field. Anyone now how to add a constraint that will only allow digits of varying character lengths? // I don't want to use integer for this field... Sent via Deja.com http://www.deja.com/ Before you buy.
how about this: CHECK (tbl_ssn between 0 and 9999999999) ? tslusser@bigfoot.com wrote: > Hi, > I want to make a varchar field that only allows numeric characters. I > have tried this: > > tbl_ssn VARCHAR(10) CHECK (tbl_ssn MATCHES '[0-9]') > > but that allows only 1 character so I tried > > tbl_ssn VARCHAR(10) CHECK (tbl_ssn MATCHES '[0-9]*') > > but that only checks the first character of the field. > > Anyone now how to add a constraint that will only allow digits of > varying character lengths? > // I don't want to use integer for this field... > > Sent via Deja.com http://www.deja.com/ > Before you buy.