Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparison problems
Message
From
26/10/2005 12:38:55
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01062225
Message ID:
01062269
Views:
13
Perfect Sergey!! Just what I was looking for.

Thanks a bunch!

~~Bonnie



>Simpler one. It's like PADL.
SELECT REPLICATE('0', 10-PATINDEX('%[^0-9]%', @StreetNumber + 'A')) + @StreetNumber
>
>>I have a StreetNumber column that is CHAR(8). It needs to be character, because you can have alpha in a street number, ie: 102A First St. The problem is that I need to provide the capability to search on a range of street numbers.
>>
>>Simply using
>>
>>WHERE StreetNumber >= '300' and StreetNumber < '500'
>>
>>won't work, because of the fact that it returns numbers like 35, 42, etc.
>>
>>But, because of the possibility of alpha characters, I cannot use CAST or CONVERT to compare numerically. I thought the answer would be to pad with leading zeros and continue to do a string comparison ... but how does one do that with T-SQL? There is no PADL statement.
>>
>>Any ideas? Or do I just need to have a cuppa coffee before I start doing too much thinking first thing in the morning? <g>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform