Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

numeric validation on a varchar field

Status
Not open for further replies.

TomBarrand

Programmer
Joined
Aug 9, 2000
Messages
162
Location
GB
I am using a varchar field in a table, but ideally I would like to put some validation on the field so that it will only accept integer values. I have to use a varchar as it causes another system a problem if the field is an int.

Any ideas on how I could validate the field would be appreciated.

Thanks
 
SQL Server 7.0 upwards you could use a check constraint on the coloumn eg:

ALTER TABLE tablename
ADD CONSTRAINT col_number_test CHECK
(column LIKE '[0-9][0-9][0-9][0-9][0-9]')

Rick.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top