I have created a SQL server project in Visual Studio 2015. We have a linked server which is referring to multiple databases. I am unable to find a way to manage this linked server and its references to multiple databases. I am unable to build the solution due to this.
Asked
Active
Viewed 819 times
1 Answers
0
There is no separate type of object on SSDT for linked servers as references. Instead, you should add database reference(s) for your remote database(s) specifying their location as "Different database, different server". Here this process is described in more detail.
You should be able to use the same SQLCMD variable as a server name for all your remote databases, though I haven't tried that myself.

Roger Wolf
- 7,307
- 2
- 24
- 33
-
We are using 5 databases of linked server. So here do we need to add 5 different projects for each database. – Pankaj Kumar Nov 23 '17 at 09:38
-
@DeveloperRego, exactly. And it their objects reference each other, you probably will have to resolve this dependency graph, as well. However, it's nearly not as frightening as it sounds if you will move all your database development into SSDT, because normally this needs to be done only once (in a while, maybe). – Roger Wolf Nov 23 '17 at 10:14
-
Hey @RogerWolf, I got your point, In my SQL Server Management Studio I can see the references to linked server are underlined in red but executed successfully. Can it be the reason for error #71561 in SQL Server db project in visual studio. If yes then please suggest any way to resolve it in visual studio. – Pankaj Kumar Dec 21 '17 at 10:43
-
1@PankajKumar, it depends on how you reference them in code. Here you can find some solutions - https://stackoverflow.com/q/12161392/3925232 – Roger Wolf Dec 21 '17 at 12:59
-
Thank you @RogerWolf for the inputs. Will try these solutions once get beck from Christmas vacation and keep you posted if more inputs needed for this concept. Wishing you Merry Christmas in advance. – Pankaj Kumar Dec 22 '17 at 12:37