|
Hi all, I want to know if anyone could help me on a string issue I’m having. I get data from a mainframe that is returning a string with some special characters in it. See below John Doe ?z1234563? Sally D ?1053442233? 1.) I want to remove the second “?” after John Doe Can someone help me on this? I’m having a very hard time. Thanks, Ben
(comments are locked)
|
|
On the face of it, the following code will do what you want, but I'm wondering whether the codes can be any length and you'd like them truncated from the left to seven characters. I'm having some difficulty in working out more exactly what the problem is that you're wanting to solve. (this code doesn't exclude those lines that don't have eight consecutive numbers after the '?'. you'd do a LIKE with the same wildcard) Phil Factor, thank you!!! This works great.
Aug 15 '11 at 06:54 AM
winnie2K
(comments are locked)
|
|
You can do any pattern matching and replacement easy by CLR RegEx implementation. You can take a look on the sample implementation SQL Server Regular Expressions – Replacements. If I understand it exactly as @Magnus Ahlkvist in the comment, then using the above implementation, you can easily run below code: If you need other results, it's only a question of passing right Regular Expressions.
(comments are locked)
|


Can you provide the query you have put together so far? Do you need to do this on every record that is returned?
Let me see if I understand your requirements. You have a column which will contain a string on the format Name ?somecode? Name ?1234567890? and you want it on the format Name ?somecode Name #4567890?. Is that correct?
I need to return on all records that meet this pattern.
In the example it's one string John Doe ?z1234563? Sally D ?1053442233?