/* * * Search & Replace * * Use Ctrl+Shift+M to replace template values * */ set xact_abort on begin tran declare @otxt varchar(1000) set @otxt = '' declare @ntxt varchar(1000) set @ntxt = '' declare @txtlen int set @txtlen = len(@otxt) declare @ptr binary(16) declare @pos int declare @id int declare curs cursor local fast_forward for select id, textptr(), charindex(@otxt, )-1 from where like '%' + @otxt +'%' open curs fetch next from curs into @id, @ptr, @pos while @@fetch_status = 0 begin print 'Text found in row id=' + cast(@id as varchar) + ' at pos=' + cast(@pos as varchar) updatetext . @ptr @pos @txtlen @ntxt fetch next from curs into @id, @ptr, @pos end close curs deallocate curs commit tran
Thursday, March 30, 2006
Search and replace in MSSQL (specifically in TEXT field)
Just use Ctrl+Shft+M in Query Analyzer to replace the parameters. Then hit "play" in query analyzer til u don't get any more hits.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment