Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 removing control characters from a string

Author  Topic 

saurabh122
Starting Member

16 Posts

Posted - 2009-09-10 : 03:24:47
Hi,

I have a string variable that has a few control characters. (control characters are the ones having their ascii values between 0 and 31). How do i remove them?

i guess using patindex we can do so. but i am somehow not able to create the regex pattern for the same.

please help.....

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-10 : 03:36:06
I would create an UDF that returns the string without control chars by stepping through the string char by char.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

saurabh122
Starting Member

16 Posts

Posted - 2009-09-10 : 04:03:35
is there any way we can accomplish this using a T-sql statement?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-10 : 04:05:26
You can change this
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/12/18/extract-only-numbers-from-a-string.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

saurabh122
Starting Member

16 Posts

Posted - 2009-09-10 : 04:11:01
thanks a lot guys....but is there a way we can eliminate the looping?
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-10 : 04:32:59
This would need real regex and that isn't in T-SQL.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -