Perhaps: substring(cast([thisfield] as varchar(50)),1,1)|||I don't know how the performance of this will compare, but if thisfield is non-negative, this should work as well:
[thisfield] / power(10, cast(log10([thisfield] as int))
Cheers,
-Isaac
|||
I hate to ask this, but the giant pink elephant in the room is "how do you have an int that doesn't start with a number?" What it sounds like you have is a column of string values that may or may not be an integer, and you want to see if the first character of the string is a number, right? For this it is:
thisColumn like '[1234567890]%'
But if the column is supposed to only contain integers, the best way to make sure that they are integers is to create the column using an integer datatype.
No comments:
Post a Comment