How do I do a simple 'Find and Replace" in MsSQL?

前端 未结 5 662
别那么骄傲
别那么骄傲 2020-12-12 23:12

Question is pretty self explanitory. I want to do a simple find and replace, like you would in a text editor on the data in a column of my database (which is MsSQL on MS Win

5条回答
  •  孤街浪徒
    2020-12-13 00:09

    like so:

    BEGIN TRANSACTION; 
    UPDATE table_name
      SET column_name=REPLACE(column_name,'text_to_find','replace_with_this'); 
    COMMIT TRANSACTION;
    

    Example: Replaces

    BEGIN TRANSACTION; UPDATE testdb
    SET title=REPLACE(title,'script','a'); COMMIT TRANSACTION;
    

提交回复
热议问题