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
 Help with procedure replacement...

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-04-19 : 11:07:14
I need to update Dist from 808 to D18

I tried this but it updated too many rows:

Update iclaimsYrTemp
set Dist = Replace(Dist, '808', 'D18')

What am I doing wrong?

Do I need a where clause?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-19 : 11:10:00
if you need to replace only exact ones do:-

Update iclaimsYrTemp
set Dist = Replace(Dist, '808', 'D18')
where Dist='808'


replace will replace the occurances of pattern wherever it can find it, even within column values

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

Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-04-19 : 11:16:30
Thanks the where clause is what I needed as you are right it did replace them all because I didn't specify. I'm find now.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-19 : 11:17:34
ok great

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

Go to Top of Page
   

- Advertisement -