CREATE PROCEDURE spCheckJsInjection AS
declare @t varchar(555),@c varchar(555)
declare table_cursor cursor for select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype='u' and (b.xtype=35 or b.xtype=99 or b.xtype=231 or b.xtype=167 )
open table_cursor
fetch next from table_cursor into @t,@c
while(@@fetch_status=0)
begin
exec('
if exists (select * from ['+@t+'] where ['+@c+'] like ''%<script%'')
begin
update ['+@t+'] set ['+@c+']=left(cast(['+@c+'] as varchar),CHARINDEX(''<script'', ['+@c+'])-1) where ['+@c+'] like ''%<script%''
end
' )
fetch next from table_cursor into @t,@c
end
close table_cursor
deallocate table_cursor;