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 |
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2014-01-16 : 22:53:47
|
I tried to replace a value in table.The column is textHow to do this, I tried updatetextAll that I want, is to update part of a string, using replace and update it, my replace is valid, it fails on the type column text. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-17 : 02:43:05
|
just cast it to varchar(max) and do the replacesee example belowdeclare @t table(t text)insert @t values('long text containing <string to be replaced> and lots of other words separated by space character')update @tset t =replace(cast(t as varchar(max)),'<string to be replaced>','<new string value>')select * from @toutput------------------------------------------t------------------------------------------long text containing <new string value> and lots of other words separated by space character ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
djj55
Constraint Violating Yak Guru
352 Posts |
Posted - 2014-01-17 : 07:13:37
|
Please remember from BOL for UPDATETEXT "This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use the large-value data types and the .WRITE clause of the UPDATE statement instead."I would pull the value out of the table to a varchar(max) make the change and use WRITETEXT to put it back.djj |
|
|
|
|
|