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 Administration
 Need help with what should be a simple SQL query

Author  Topic 

etaine
Starting Member

2 Posts

Posted - 2010-05-04 : 13:32:59
I run a forum and I have added a bbcode mp3 tag that when wrapped around a post will embed the mp3 player directly into the post. This is not an issue and works as expected.

What I would like to do is find a way to do this to posts that have already been created.

Is there a way to do a sort of find/replace or add across the table?

basically I want to find all statements such as http://%%%%%%%%%%.mp3 and append [mp3] [/mp3] to the beginning and end.

Any help with this would be appreciated.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-04 : 13:36:35
[code]UPDATE Table
SET field= '[mp3]' + field + '[/mp3]'
WHERE field LIKE 'http://%.mp3'
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-04 : 13:39:54
update table
set column=replace(replace(column,'http://','[mp3]http://'),'.mp3','.mp3[/mp3]')
where column like 'http://%.mp3'


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

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-04 : 13:40:55
Too late...
And visakh's solution looks better


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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-04 : 13:45:38
Thanks

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

etaine
Starting Member

2 Posts

Posted - 2010-05-04 : 13:54:33
Thanks a lot guys. I knew is was easy, heck I knew I'd done it before but its just been a while.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-04 : 13:57:49
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -