If you have two database projects, ReportDb and DependentDb, you might want to reference objects in DependentDb from ReportDb. You start by adding a reference in the properties of the DependentDb database project and define variables as follows:
The value for RefServer is the name of the server upon which DependentDb resides. The value for RefDatabase is the name of the target database that is deployed by the DependentDb project. In this example, RefServer has the value StageSvr and RefDatabase has the value DepDb.
You could add a view to ReportDb that selects all columns from the Employee table in the DependentDb that is deployed to the database that is named DepDb on the server named StageSvr. You would create the object definition for that view as follows:
|
CREATE VIEW [dbo].[DependentView]
AS
SELECT * FROM [$(RefServer)].[$(RefDatabase)].[dbo].[Employee]
; |