devxlogo

Validating the Data Type in a T-SQL Query

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 MyTableCompanyID   MyValue----------- -------1           201           101           401           AB(4 row(s) affected)select * from MyTable where ISNUMERIC(MyValue)=1CompanyID   MyValue----------- -------1           201           101           40(3 row(s) affected)select * from MyTable where ISNUMERIC(MyValue)=0CompanyID   MyValue----------- -------1           AB(1 row(s) affected)
See also  Is Machine Learning Automating Creativity in Graphic Design?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist