Apr 11, 2006 #1 SteveMe MIS Aug 30, 2002 83 US DECLARE @Str as varchar(200) Set @Str = 'a123b432c' so that @Str will equal 1bc. I will not know how many numbers or if there are numbers in a string. The patterns will be different.
DECLARE @Str as varchar(200) Set @Str = 'a123b432c' so that @Str will equal 1bc. I will not know how many numbers or if there are numbers in a string. The patterns will be different.
Apr 11, 2006 #2 SQLDenis Programmer Oct 1, 2005 5,575 US One way DECLARE @Str as varchar(200) Set @Str = 'a123b432c' select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(@Str,'1',''),'2',''),'3',''),'4',''),'5',''),'6',''),'7',''),'8',''),'9',''),'0','') Denis The SQL Menace SQL blog:http://sqlservercode.blogspot.com/ Personal Blog:http://otherthingsnow.blogspot.com/ Upvote 0 Downvote
One way DECLARE @Str as varchar(200) Set @Str = 'a123b432c' select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(@Str,'1',''),'2',''),'3',''),'4',''),'5',''),'6',''),'7',''),'8',''),'9',''),'0','') Denis The SQL Menace SQL blog:http://sqlservercode.blogspot.com/ Personal Blog:http://otherthingsnow.blogspot.com/
Apr 11, 2006 #3 gmmastros Programmer Feb 15, 2005 14,912 US 10 replace statements.... DECLARE @Str as varchar(200) Set @Str = 'a123b432c' Set @Str = Replace(@Str, '0', '') Set @Str = Replace(@Str, '1', '') Set @Str = Replace(@Str, '2', '') Set @Str = Replace(@Str, '3', '') Set @Str = Replace(@Str, '4', '') Set @Str = Replace(@Str, '5', '') Set @Str = Replace(@Str, '6', '') Set @Str = Replace(@Str, '7', '') Set @Str = Replace(@Str, '8', '') Set @Str = Replace(@Str, '9', '') -George Strong and bitter words indicate a weak cause. - Fortune cookie wisdom Upvote 0 Downvote
10 replace statements.... DECLARE @Str as varchar(200) Set @Str = 'a123b432c' Set @Str = Replace(@Str, '0', '') Set @Str = Replace(@Str, '1', '') Set @Str = Replace(@Str, '2', '') Set @Str = Replace(@Str, '3', '') Set @Str = Replace(@Str, '4', '') Set @Str = Replace(@Str, '5', '') Set @Str = Replace(@Str, '6', '') Set @Str = Replace(@Str, '7', '') Set @Str = Replace(@Str, '8', '') Set @Str = Replace(@Str, '9', '') -George Strong and bitter words indicate a weak cause. - Fortune cookie wisdom