June 3, 2008 at 12:40 pm
I need to check for the existence of any character other than a–z, A–Z, 0–9, –(hyphen), and _ (underscore) in a string and replace the character by an underscore. What is the best way to do this? The string here will be a field in a table and this will be in the select part of a query in a stored procedure.
June 3, 2008 at 1:02 pm
you can create a UDF to parse a string then use it on the SELECT list.
* Noel
June 3, 2008 at 1:24 pm
A CLR Regex will be the fastest way to do this.
Check out this thread on the subject:
http://www.sqlservercentral.com/Forums/Topic470379-338-1.aspx
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 3, 2008 at 1:42 pm
Thanks for the help. I could go with regex.
June 3, 2008 at 3:19 pm
definitely a CLR function will be the best bet ...IF ... you have CLR enabled 😉
* Noel
June 3, 2008 at 8:32 pm
Lacking an XLATE() type built-in function in T-SQL, CLR is probably the way to go.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
June 3, 2008 at 9:52 pm
So, the question would be...
... are you allowed to use CLR's on your system?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply