VS2013 Database Project how to reference other database projects in solution VS2013 Database Project how to reference other database projects in solution sql-server sql-server

VS2013 Database Project how to reference other database projects in solution


It sounds like you're still using the existing three part name (e.g. [SameServerDb].[dbo].[Table2]) in your stored procedures and views. You should update it to use the SQLCMD variable name for the reference instead. SQLCMD variables are used so that you could change the referenced database name at deployment time.

This is covered in the help documentation, but here's an example for you. In this case I added a reference to "SameServerDb" as shown below:

Add Database Reference Dialog

Note the "Database Variable" name is $(SameServerDb). Now I just change any reference from [SameServerDb] to [$(SameServerDb)]:

CREATE VIEW [dbo].[View2]AS SELECT * FROM [$(SameServerDb)].[dbo].[Table2]


For all database projects in your solution, add all their referenced databases: In Solution Explorer window, right click References -> Add database reference, and select the other project. Repeat for all referenced projects. Also, make sure you rebuild all projects.

You can also suppress certain warnings:http://social.msdn.microsoft.com/Forums/sqlserver/en-US/9b698de1-9f6d-4e51-8c73-93c57355e768/treat-specific-warning-as-error?forum=ssdt