The problem
When using the Visual Studio SQL Compare to compare your database schema to your physical database it returns heaps of false positives, where SQLCompare is suggesting that your CMD variable does not match what is on the database.
The Solution
SQLCompare uses the default or local CMD variables that you have on your project when performing the compare.
You need to ensure the default variables match the target database you are comparing against.
To change your defaults open the properties of your Database project, switch to the “SQLCMD Variables” tab and edit the defaults.
When you get your variables in alignment with your target comparison database you will get a true indication of the differences.
Somehow that does not work for me.
I have two database projects in a solution (VS 2012), one referencing another. The SQLCMD variable AnotherProject, denoting the referenced database, was automatically added, with the default value set to the name of the referenced project. I substituted it with a physical database name [ServerName].[DatabaseName], moving the old default to Local, built the solution, ran Schema Compare.
In the Synonims, where I had substituted the database references with [$(AnotherProject)].[dbo].[…, the variable is not resolved to the default value during the comparison.
A few points.
Hope that helps.
I had similar issue can you help me
https://www.experts-exchange.com/questions/29019865/Powershell-compare-DACPAC.html
I think the problem is your code in the left hand example of the compare is wrong. You have the variable $(testDB) NOT $(Database_Name)
So the procedure should be;
select 1 from [$(testDB)].dbo.tblTest
If you do this correctly the procedure will not be found to be different, and it will NOT show up in the schema compare results.
If you do have a record with a difference lets say:
select 1 from [$(testDB)].dbo.tblTest with(nolock)
The compare will find a difference and it will highlight both the “with(nolock)” and the [$(testDB)]. You can ignore the [$(testDB)] as it is just the simplistic compare utility not being smart enought to replace it with your variable.
Hope this helps
Hi the variable I am passing is correct but still I couldn’t compare them properly
Here I am comparing with the one that got extracted after database got published so here is the diff it is showing
CREATE PROCEDURE [dbo].[Procedure1]
AS
SELECT * from [$(Database_Name)].dbo.tbltest
RETURN 0
GO
CREATE PROCEDURE [dbo].[Procedure1]
AS
SELECT * from [TaxDB].dbo.tbltest
RETURN 0
GO