Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Beginner
Mar 5, 2003

Validating the Data Type in a T-SQL Query


Using the ISNUMERIC() and ISDATE() functions, you can check the required column's data type validity. If the column passes the data type validity check, it will return a 1. If it fails, it will return a 0.

Example:
 
select * from MyTable

CompanyID   MyValue
----------- -------
1           20
1           10
1           40
1           AB

(4 row(s) affected)


select * from MyTable where ISNUMERIC(MyValue)=1

CompanyID   MyValue
----------- -------
1           20
1           10
1           40

(3 row(s) affected)


select * from MyTable where ISNUMERIC(MyValue)=0

CompanyID   MyValue
----------- -------
1           AB

(1 row(s) affected)
Somaiah Manukonda
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date