Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove damage caused by SQL injection

Status
Not open for further replies.

stocktondesigns

Technical User
Aug 31, 2003
16
US
I have a table in our SQL database that has a bunch of hacker URL's appended to about 80,000 rows. I would like to go into each row and erase the offending characters, maintaining my originally entered data. My current approach is to do a search/replace with the table open, however, this is taking a really long time. Is there a faster way to execute this kind of cleanup? It's the same value in every record in about 3 or 4 fields.

I'd truly appreciate any help.
 
a simple SQL update will do the trick if the string is always same size or always at the end of your data.

example.

update my_tbl set f1 = SUBSTRING(f1,1,charindex('ABC',f1) - 1);

where ABC is the string you want to replace.



Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
If the string is the same and if you want to keep all information but that string you could use REPLACE Function:
Code:
UPDATE YourTable SET TheField = REPLACE(TheField,OffendedString,'')

Be sure you have a good backup first.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
fredericofonseca,
your suggestion makes sense, however, when I try to run it, I get an error telling me 'invalid legth parameter passed to the substring function'

 
Append this WHERE clause:

WHERE (charindex('ABC',f1) - 1) > 0

HTH,

Phil H.
Some Bank
-----------
Time's fun when you're having flies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top