0

I am in need of some help. Thanks to fellow user davids, I was able to get certain things working within SQL Server and am in need of some more help. Here is what I am trying to do:

UPDATE Table1 SET keyfield=(REPLACE(REPLACE(Column1,'http://*/folder/',''),'.avi',''))
UPDATE Table2 SET keyfield=(REPLACE(REPLACE(Column2,'http://server2/folder/',''),'.mpg',''))

Can anyone help me out or point me in the right direction to get the wildcard to work? This particular column, the * is an IP Address and it will change all the time. Granted I will know the IP's ahead of time and can probably do it one by one, but I would prefer to have it automatically replace. Thanks in advance!

1
  • 1
    Can you add a before and after for the keyfield? Commented Nov 6, 2012 at 14:41

1 Answer 1

0

You should look into regular expressions.

My google karma found this article in MSDN Magazine.

Edit:

See also: Perform regex (replace) in an SQL query

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for pointing me in the right direction. After looking at everything I had to revamp what I was doing. In the process I also figured out an easier way for me to do the replace in the process. Figured out my issue and learned something new, thank you for the help!
your google karma has expired: that link doesn't work any more.
@Brad The woe of link-only answers. Not sure what to do. The question has a great subject line (but is otherwise not great). The accepted answer of the question I link to in the Edit does a great job of answering this question. My answer doesn't provide any additional value. I propose that we try to close this question as a dupe so that people who find it get directed to a proper answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.