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
 Update multiple rows - not getting it right

Author  Topic 

berndh
Starting Member

6 Posts

Posted - 2006-01-03 : 06:14:16
Hi all,

I need to write an SQL statement to update multiple row (all) as follws and can just not get it right please help.

I have two fileds - "Tilte" and "Title1" in my "notes" table.

I would like to run through the entire table and replace the information in "Title1" with that of "Title", also I need to change a character whilst doing so , ie change a "=" to a "-"

Example
Title - "Will is coming to town = Paul"

need to copy this to Title1 and it must change to...

Title1 - "Will is coming to town - Paul"

Running MS SQL2000 SP4

Help appriciated
Thanks

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2006-01-03 : 06:26:18
this will help you
update notes set title1 = replace(title,'=','-')
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-03 : 06:46:01
If it is only for display you can use

Select replace(title,'=','-') as title from notes

Madhivanan

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

berndh
Starting Member

6 Posts

Posted - 2006-01-03 : 08:14:27
Thanks guys. Working.

Go to Top of Page
   

- Advertisement -