sql server 2005 - Getting first n numeric characters from a varchar column in SQL -


I am creating a hash, I'm using a home number from an address area. Which SQL can I use to select only numeric characters in front of a varchar field?

EX:

  12345 South 1st Street  

I need 12345 . thank you in advanced.

  @ MyColumn varchar (250) Set @MyColumn = '12345 < / Code> 

If you do not, then make my first call @ (my name), cast (left (@mcal column, petindex ('% [^ 0-9]%', @MyColumn )) To prevent errors, add a case statement to ensure that there will be a number:

  declare @ as MyColumn varchar (250) Set @MyColumn = 'Patidx ('% [^ 0- 9]% ', @ my column) = 1 then left' 'and (@My column, the box Dex ('% [^ 0-9]% as StreetNumber),  

If there can be any spaces, then you LTRIM :


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -