SOLVED

How to replace linked server calls in SQL server?

%3CLINGO-SUB%20id%3D%22lingo-sub-2705369%22%20slang%3D%22en-US%22%3EHow%20to%20replace%20linked%20server%20calls%20in%20SQL%20server%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2705369%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20two%20SQL%20Server%20database%20instances%20-%20let's%20call%20them%20server%20A%20and%20B.%3C%2FP%3E%3CP%3ESadly%2C%20as%20the%20user%20traffic%20decreases%2C%20there%20is%20now%20no%20need%20for%20running%20two%20servers%20anymore.%20So%20I'm%20planning%20to%20merge%20databases%20on%20server%20B%20to%20A.%3C%2FP%3E%3CP%3EBut%20here's%20the%20problem%3A%20there%20are%20thousands%20of%20stored%20procedures%20and%20triggers%20on%20server%20A%20that%20connects%20to%20server%20B%20through%20linked%20server%20and%20vice%20versa.%3C%2FP%3E%3CP%3EWhen%20merged%2C%20there%20is%20no%20need%20to%20use%20linked%20server%20so%20I'm%20going%20to%20have%20to%20replace%20all%20of%20them.%3C%2FP%3E%3CP%3EIt%20might%20be%20possible%20to%20keep%20linked%20server%20and%20make%20it%20to%20point%20itself%3F%20But%20it%20seems%20like%20a%20bad%20practice.%3C%2FP%3E%3CP%3EHow%20can%20I%20effectively%20replace%20all%20of%20them%3F%20Do%20I%20have%20to%20write%20thousands%20of%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EALTER%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ESQL%20scripts%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2705369%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELinked%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Frequent Visitor

I have two SQL Server database instances - let's call them server A and B.

Sadly, as the user traffic decreases, there is now no need for running two servers anymore. So I'm planning to merge databases on server B to A.

But here's the problem: there are thousands of stored procedures and triggers on server A that connects to server B through linked server and vice versa.

When merged, there is no need to use linked server so I'm going to have to replace all of them.

It might be possible to keep linked server and make it to point itself? But it seems like a bad practice.

How can I effectively replace all of them? Do I have to write thousands of ALTER SQL scripts?

1 Reply
best response confirmed by intackchoi (Frequent Visitor)
Solution

@intackchoi , use SSDT = SQL Server Database Tools, create a database project, import database design, replace all references to the linked server and deploy the changes to your SQL Server.

 

See Import into a Database Project