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 |
Gingerr
Starting Member
1 Post |
Posted - 2012-04-21 : 18:53:11
|
I'd like to replace a four character string in a field in a 2005 sql table that has other information of varying lengths (so I can never pinpoint where the text I want to replace will be).Let's say the text is GING and I want to replace with LIST everywhere it exists in the field. For example the field might have Archer Road GING 3980 Fairmont Circle.... in one record, Penople Street GING 6543 Main Street .... in another etc.I see you can replace the whole field with a replace statement but can't find where you can replace text within the field, something like thisUpdate mattersset shortdesc = replace(select '%GING%', 'GING', 'PING')This didn't work of course.... |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-21 : 19:14:35
|
[code]Update mattersset shortdesc = stuff(shortdesc,patindex('%GING%',shortdesc) ,4, 'PING')[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|