August 5, 2011 at 11:33 am
i'm trying to remove all non alphnumberic characters at the front of the string. I was thinking to isolate the position of the first alpha numberic character using charindex or patindex then chop off everything before it. If i have to i'll use the asci ranages and go through char by char however i was hoping sql server 2008 has a beter way to identify an alphanumeric.
declare @string varchar(100)--the below has carrage returns and tabs before the actual string hello world starts.
set @string = '
hello world'
--output = 'hello world'
--output: 'hello world'
August 5, 2011 at 11:37 am
August 5, 2011 at 10:07 pm
SELECT SUBSTRING(@String,PATINDEX('%[A-Z0-9]%',@String),100)
--Jeff Moden
Change is inevitable... Change for the better is not.
August 6, 2011 at 3:26 am
Jeff, how does that remove multiple non consecutive "wrong" characters?
August 6, 2011 at 12:14 pm
It doesn't and that wasn't a part of what the OP asked for.
i'm trying to remove all non alphnumberic characters [font="Arial Black"]at the front of the string[/font]
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply