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 |
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2008-06-20 : 10:38:22
|
| Trying to update a field in a table where the first 5 characters are Pr160. I want to replace PR160 with PRQTE.I get incorrect Syntax near "LEFT" on line 2.update oeprcfil55_sqlset LEFT(filler_0001,5) = 'PRQTE'WHERE LEFT(FILLER_0001,5) = 'PR160' |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2008-06-20 : 10:46:37
|
| update oeprcfil55_sqlset FILLER = REPLACE(FILLER,'PRI60','PRQTE')WHERE LEFT(FILLER_0001,5) = 'PR160'Jim |
 |
|
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2008-06-20 : 10:49:07
|
| there is other data in the filler field that I want to keep in place. Will that data remain? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-20 : 10:52:02
|
quote: Originally posted by Vack there is other data in the filler field that I want to keep in place. Will that data remain?
It will remain. the only probelm that can happen is if you've multiple instances of PRI60 in your field, it will replace all instances into PRQTE instead of first alone. But if such a case wont occur, then there's no problem. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2008-06-20 : 10:58:30
|
| Maybe this would be better, Visakh? update oeprcfil55_sqlset FILLER = STUFF(FILLER,1,5,'PRQTE')WHERE LEFT(FILLER_0001,5) = 'PR160'Jim |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-20 : 11:05:05
|
quote: Originally posted by jimf Maybe this would be better, Visakh? update oeprcfil55_sqlset FILLER = STUFF(FILLER,1,5,'PRQTE')WHERE LEFT(FILLER_0001,5) = 'PR160'Jim
yup. this will do good STUFF! |
 |
|
|
|
|
|
|
|