I’ve been charged with the task of moving a database from ServerA to ServerB. ServerB contains many other database objects, a fair few using a Linked Server connection to ServerA. For example, there may be a view which joins a table1 on ServerB to ServerA.database.schema.table1
Does anyone know of a script I can run on ServerB that will display a list of all objects that reference ServerA, so that I may update them quickly, without having to open each object.
I hope this makes sense. Thanks
This has the potential for false positives, but that is probably better than relying on dependency views (which will miss dynamic SQL or simply out-of-date dependencies):
You may also need to account for potential cases where the server name is enclosed in square brackets:
You should also consider using SYNONYMs to prevent this type of maintenance in the future. In fact you may also want to check for any synonyms that reference the server name: