-1

I have a SQL Server database called school. I just want to find a string called www.yahoo.com and replace with www.google.com.

I have the find and replace do in whole database anyone can put a example of code of SQL query to do that?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
field3d
  • 1
  • 3
  • 1
    Meaning you have to search every single column in every single row in every single table? There is no simple way to do this. And there is no fast way to do this either. – Sean Lange Sep 09 '15 at 14:40
  • Is the database normalized, so that the searched string is in a specific table? – CPMunich Sep 09 '15 at 14:50
  • Is the search string the sole content of a table column "some where in one of your tables" or could it even be part of a bigger (surrounding) text? – Shnugo Sep 09 '15 at 14:53
  • See [How do I find a value anywhere in a SQL Server Database?](http://stackoverflow.com/q/436351/4275342) – Roman Marusyk Sep 09 '15 at 14:58
  • This didn't help you? It came up as the first result when I googled: https://www.mssqltips.com/sqlservertip/1555/sql-server-find-and-replace-values-in-all-tables-and-all-text-columns/ – Tab Alleman Sep 09 '15 at 14:59
  • I think the last link is what I need I'll test. – field3d Sep 09 '15 at 15:27

1 Answers1

0

Please try below query on a particular column in SQL Server:

UPDATE school
SET column_name = REPLACE(column_name,'www.yahoo.com','www.google.com')
WHERE column_name LIKE '%www.yahoo.com%'
fez
  • 1,726
  • 3
  • 21
  • 31
Anshul Dubey
  • 349
  • 4
  • 14