Hello,
I was wondering if there is any method that I can use to determine if a field (defined as text) has any character fields or is really a number. I want to figure out if a field is truly all numeric, and out of curiosity, was wondering if there was a way in SQL or T-SQL.
Thanks.
look at SQL Server function IsNumeric. It return 1 if it is, otherwise 0. You can use it with CASE WHEN. If it is numeric, get it, otherwise, set to other value such as 0.
|||You can check whether the following will work for you:
WHEREyourColumnNOTLIKE'%[^0-9]%'
or
WHERE IsNumeric(yourColumn)=1
|||
Hey,
I didn't know there was an IsNumeric method... and I'm using SQL 2000 so regular expression's won't work for me. Sorry I should have mentioned the 2000 part.
Thanks.
No comments:
Post a Comment