Declare @ t varchar (255 ),
@ C varchar (255 ),
@ SQL varchar (4000 ),
@ STR nvarchar (300)
Set @ STR = '"> </title> <SCRIPT src = http: // %'
Declare @ d_str varchar (8000)
Set @ d_str =''
Declare @ t_str varchar (8000)
Set @ t_str =''
Declare table_cursor cursor
Select
A. Name, B. Name
From sysobjects,
Syscolumns B
Where a. ID = B. ID and
A. xtype = 'U' and
(B. xtype = 99 or B. xtype = 35 or B. xtype = 231 or B. xtype = 167)
Open table_cursor
Fetch next from table_cursor into @ T, @ C
While (@ fetch_status = 0)
Begin
-- Set @ SQL = 'Update ['+ @ T +'] Set ['+ @ C +'] = rtrim (convert (varchar, substring ('+ @ C + ', 0, charindex (''' + @ STR + ''', '+ @ C + '))))'
-- Set @ SQL = 'Update ['+ @ T +'] Set ['+ @ C +'] = substring ('+ @ C +', 0, charindex (''' + @ STR + ''', '+ @ C +') + substring ('+ @ C + ', charindex (''' + @ STR + ''', '+ @ C +') + Len (''' + @ STR + '''), len ('+ @ C +') where charindex (''' + @ STR + ''', '+ @ C +')> 0'
-- Exec (@ SQL)
Declare @ P varbinary (16), @ postion int, @ rplen int
Set @ t_str = 'select' + @ P + '= textptr (' + @ C + '),' + Cast (@ rplen as nvarchar (10 )) + '= Len (''' + @ STR + '''),' + Cast (@ postion as nvarchar (10 )) + '= charindex (''' + @ STR + ''',' + @ C + ')-1 from' + @ t
Print @ t_str
Exec (@ t_str)
While cast (@ postion as INT)> 0
Begin
Exec ('updatetext '+ @ T +'. '+ @ C + ''+ @ P +'' + @ postion + ''+ @ rplen +'' + @ d_str)
Exec ('select' + @ postion + '= charindex (''' + @ STR + ''',' + @ C + ')-1 from' + @ T)
End
Fetch next from table_cursor into @ T, @ C
End
Close table_cursor
Deallocate table_cursor