Hello I am working on a SQL database
Using Microsoft SQL server 2008 R2
And Microsoft SQL Server management studio
I have a Database Called FixedNamesDb
On the database there is one table called All
It is similar to this (this is an example):
OldNames NewNames
------------+---------------+
tom G Thommas Grady
Kate F Kateline Farwell
John S Jhon Smith
In another Database Called DescriptionDb There is lots of tables Table1, Table2, Table3 ….
Foreach Oldname in the FixedNamesDb I need to search all the tables in the DescriptionDb and if the oldname appears in any field i need to replace it with the newName
I search all the tables in DescriptionDb for a field containing “John S” and replace it with “Jhon Smith”
Any help on how to do this automaticaly? Usding a script, a query or something else.
More info:
-
Each Name Appears only one time in one of the tables of DescriptionDb
-
All the names appears (there is no name that does not exists)
-
All the names are located in the Second Row of the table (Row where ID=2)
Thanks a lot for any help.
Use this script for each table that needs to be updated.
The following script can find all tables and columns. Using a programming or scripting language loop through all tables and columns replacing
Table1andNamein the above script with all iterations of the script below.