MSBuild.Sdk.SqlProj icon indicating copy to clipboard operation
MSBuild.Sdk.SqlProj copied to clipboard

Support for linked servers

Open marcadella opened this issue 2 years ago • 5 comments

I get a lot of unresolved references to resources living on a linked server. Is there a way to define the linked server in the project? Or is there a way to somehow ignore such errors?

marcadella avatar Oct 26 '23 14:10 marcadella

Please share the exact errors you get

ErikEJ avatar Oct 26 '23 14:10 ErikEJ

Given the sql: ... from LBR_ROLLE P join [ILPROD2]..[LBR].[LBR_ROLLE] L on L.id = P.id, I get: "error SQL71501: SqlView: [dbo].[vPROD_LBR_ROLLE_DIFF] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [dbo].[LBR_ROLLE].[L]::[ID], [ILPROD2].[].[LBR].[LBR_ROLLE].[ID] or [ILPROD2].[].[LBR].[LBR_ROLLE].[L]::[ID]." I don't really see why [ILPROD2]..[LBR].[LBR_ROLLE] is ambiguous and it looks like the model doesn't know how to handle ILPROD2 which is a linked server.

marcadella avatar Oct 27 '23 07:10 marcadella

Have a look here: https://github.com/rr-wfm/MSBuild.Sdk.SqlProj#package-references

ErikEJ avatar Oct 27 '23 09:10 ErikEJ

Thanks for your answer. The thing is that I don't have any .dacpac for that linked server. Is it somehow possible to tell the tool to ignore missing dependencies for this linked server? I see in the doc that one can use SuppressMissingDependenciesErrors, but it looks like it only works with a package or project reference, but in my case I have none.

marcadella avatar Oct 27 '23 09:10 marcadella

The approach for working with linked servers is a dacpac for the linked server objects as described here;

https://www.mssqltips.com/sqlservertip/3331/how-to-use-a-linked-server-in-a-sql-server-database-project/

ErikEJ avatar Mar 16 '24 16:03 ErikEJ