Wednesday, August 13, 2008

How to Replace a text in SQL Server Table Column

If you have a Table which has a Column of type char or varchar or even text, and you want to change a portion of text in it for example a path.
In this case you need to change the same text with new one in every records.

Here is the SQL Statement that do this:
UPDATE [TableName] SET [ColumnName] = Replace([ColumnName],'OldText','NewText');

Source: https://www.nilebits.com/blog/2007/09/replace-text-in-a-column-in-sql-server/

6 comments:

  1. Thanks ,it 's very good , but i want to ask how can i put a picture uploaded from my website in a certain column in my SQL in direct way(by the way i make the column binary datatype)
    thanks for u
    A.B

    ReplyDelete
  2. Replace() doesn't work with text columns

    ReplyDelete
  3. Thanks it worked a treat. I like your syntax names, clear!

    ReplyDelete
  4. Hello everyone i am completely new to this forum.
    Interested in learning many new things. Hope we all will share our
    knowledge and talk about different concepts in this forum.

    ReplyDelete
  5. You are welcome, but this is not a forum it is a blog.
    Anyway if you have something you want to share send it to me and I will post it and mention your name at the bottom of the article.
    This is my email amr.saafan@hotmail.com

    ReplyDelete
  6. What do you mean?

    ReplyDelete