microsoft / microsoft/vscode-mssql
[Bug]: Schema Compare flags cross-database references using variables as code differences
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 610
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 97
Description
### Description
**Description**
When performing Schema Compare on a database project, tables that reference objects in another database via a SQLCMD variable (e.g. [$(OtherDatabase)]) are incorrectly flagged as code differences, even though the logical definition of the object is the same.
This makes Schema Compare noisy and unreliable for projects that correctly use variables for cross-database references.
**Expected Behavior**
Schema Compare should treat cross-database references that use SQLCMD variables as equivalent, provided the resolved object definitions are the same.
Tables should not appear as different solely because a database name is parameterized via a variable.
Additionally, it would be helpful to add an option to the schema compare to ignore differences in the first part of 4 part names (Database Name)
### Steps to Reproduce
Actual Behavior
Schema Compare reports a code difference for tables that include cross-database references using variables such as:
`SELECT *
FROM [$(OtherDatabase)].dbo.SomeTable;`
### Affected Area
- [ ] Connection dialog (SQL Server | Azure browse/Fabric browse)
- [ ] Query editor
- [ ] Query results panel
- [ ] Object Explorer
- [ ] GitHub Copilot integration
- [ ] Preview/Edit data
- [ ] Table Designer
- [ ] Schema Designer
- [x] Schema Compare
- [ ] Local SQL Server Container provisioning
- [ ] SQL database in Fabric provisioning
- [ ] DACPAC/BACPAC export/import
- [ ] SQL Database projects
- [ ] Query Plan Visualizer
- [ ] Other (please describe below)
### If you selected "Other", please describe the affected area
_No response_
### Environment Information
vscode: 1.108.2
mssql: 1.39.0
sql project: 1.5.6
### Confirmation
- [x] I have searched existing issues and couldn't find a match
- [ ] I want to work on this issue
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.