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.
| Author |
Topic |
|
gavakie
Posting Yak Master
221 Posts |
Posted - 2010-07-01 : 11:40:32
|
| I have a column name strReportNameIn the I have random like like pet count by year or pet county by manufactorer.I need to replace "pet" with "vehicle" where it appears on certain rows. |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-07-01 : 11:44:56
|
| [code]UPDATE tablenameSET strReportName = Replace(strReportName,'pet','vehicle')WHERE (condition to select the certain rows)[/code] |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-07-02 : 05:02:42
|
| Make sure that you want to replace pet straigtht way if it comes any where in the column value like petal will be replaced by vehicleal.Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-02 : 05:08:57
|
For the given examples this would work:update tableset strReportName = replace(strReportName,'pet coun', 'vehicle coun')where strReportName like '%pet coun%' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-07-02 : 05:55:39
|
quote: Originally posted by webfred For the given examples this would work:update tableset strReportName = replace(strReportName,'pet coun', 'vehicle coun')where strReportName like '%pet coun%' No, you're never too old to Yak'n'Roll if you're too young to die.
it can be like this to be more generalized - update tableset strReportName = replace(strReportName,'pet ', 'vehicle ')where strReportName like '%pet %'Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
|
|
|