I have a a system with two databases, main database and audit database. A lot of the triggers and table views in the main database and audit database are referencing from one database to the other. No I needed to change both databases names but unfortunately they failed to work because they still have the old names in the code.
Is there a code to search and replace the old name used for referencing or in dependence?
Thank you,
Best Answer
You can use the text column from
sys.all_sql_modules
to create alter scripts with your new database names. Below is an example where I use AdventureWorks2014 to replace any text where there is aCREATE
with anALTER
while changing database nameHumanResources
toHR
. Again this will only generate your scripts.EDIT: Replaced
syscomments
withall_sql_modules
. Thanks Kenneth Fisher!Hope this helps!