Is there an option to parse SQLCMD-variables doing a comparison in Visual-Studio schema-comparison?
Asked Answered
A

2

6

It looks like Visual Studio Database Project does not parse SQLCMD-variables doing a schema-comparison.

All my synonyms looks like

CREATE SYNONYM [dbo].[addressesExtDB] FOR [$(ExtDB)].[dbo].[addresses];

but they keep be reported as different from the database.

When I do a schema update with the correct 'Specify SQLCMD Variabeles...'-settings where the var ExtDB is set to 'ExtDBnn' the resulting Synonym in the database is correctly set to:

CREATE SYNONYM [dbo].[addressesExtDB] FOR [ExtDBnn].[dbo].[addresses];

A recompare actions shows all Synonyms falsely as different again. So the compare should parse the sqlcmd-variabeles and use the results to compare with the database. Do I miss an option to do this or something, or did you experience the same problem and found a solution somehow?

Autotruck answered 14/11, 2012 at 9:6 Comment(0)
H
0

No, variables are not passed to schema comparison in VS at all (you can verify this by e.g. adding your own contributor to the project).

Interestingly, even when using SqlPackage.exe, variables are passed only to source, not to target.

When faced with this, I ended doing database name -> variable substitution in a .dacpac file fetched from database - everything works that way, even though it is quite a hack.

Hexaemeron answered 8/12, 2014 at 17:14 Comment(0)
L
0

Set the Default for the Variable in the project settings. The SchemaCompare will then assume they are equal.

SQLCMD VARIABLES

Schema-Compare without sqlcmd variable Default

Schema-Compare with sqlcmd variable Default

If this is not what you are getting at could you let me know and provide some clarification? Cheers

Leasehold answered 12/9, 2016 at 13:44 Comment(1)
This answer did not work for me. The schema compare shows the same results no matter what value (or blank) is set as default or local. I am running VS2019...Transferase

© 2022 - 2024 — McMap. All rights reserved.