Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I replace number
Message
 
 
To
18/02/2005 16:26:03
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00988494
Message ID:
00988535
Views:
31
You can repeat REPLACE 10 times. If numbers are always at the beginning of the column, you can use solution #2.
DECLARE @str varchar(50)

--SET @str = 'No. 1349, High Street'

SET @str = '5617 good drive way'

-- # 2
SELECT LTRIM(
 REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( 
   REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( @str, 
          '0', ''), '1', ''), '2', ''), '3', ''), '4', ''), 
          '5', ''), '6', ''), '7', ''), '8', ''), '9', ''))
-- # 2
SELECT LTRIM(REVERSE( SUBSTRING( REVERSE(@str), 1, PATINDEX('%[0-9]%', REVERSE(@str))-1)))
>In a table, we have a char column. The data like these:
>
>No. 1349, High Street
>5617 good drive way
>
>We want delete all number in this columns. We want to use Replace functiion, but we can't use range [0-9].
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform