Remove all after certain character

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fran7
    New Member
    • Jul 2006
    • 229

    Remove all after certain character

    Hi, I wonder if anyone could help. I have been hacked and one field in my database has had html and links added after the original content.


    http://www.website.com </title><style>.a jbv{position:ab solute;clip:rec t(481px,auto,au to,446px);}</style><div class=ajbv><a href=http://ma

    I need to remove everything after and including the title to leave only
    http://www.website.com

    Thanks for any help
    Richard
  • fran7
    New Member
    • Jul 2006
    • 229

    #2
    hi, I solved it like this in the nd so thanks.

    Code:
    UPDATE tbl
    SET website= LEFT(website, CHARINDEX('<', website) - 1)
    WHERE CHARINDEX(';', website) > 0
    Thanks
    Richard

    Comment

    • Luuk
      Recognized Expert Top Contributor
      • Mar 2012
      • 1043

      #3
      What?
      You search for a ';', and replace anything before a '<'
      That seems to be not the correct way!
      (but might give correct results in this situation)

      Secondly, restoring a backup might even be safer, after all someone changed thing in your system, and they might have change more than just this column.

      Comment

      Working...