Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparison problems
Message
 
 
To
26/10/2005 11:09:42
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01062225
Message ID:
01062241
Views:
19
This message has been marked as the solution to the initial question of the thread.
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>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform