adsense

Friday, January 16, 2015

SQL Server check nemeric

There can be situations where you want to check whether a field is a numeric or not. SQL Server provides ISNUMERIC() function to achieve that purpose as shown below.


SELECT case when IsNumeric(cmp) = 1
       then cast(cmp as int)
       else 0 end   FROM Transactions)

This can be easily included in a where clause as follows

select * from Transactions 
where (case when IsNumeric(cmp) = 1
       then cast(
cmp as int)
       else 0 end) >= 7

 
Cheers
Samitha

No comments:

Post a Comment