What are the challenges you face when working across database platforms? Take the survey

SQL Compare Source Control Problem

SteveGTRSteveGTR Posts: 91
edited September 23, 2014 3:32PM in SQL Compare Previous Versions
I'm developing a database drift process that uses snapshots created by SQL Compare version

The process uses PowerShell and goes like this:

1) Create snapshot by getting latest from source control (TFS)

& sqlcompare /force /makesnapshot:c: empmydb.snp /server1:. /database1:mydb /Revision1:HEAD

2) I run a SQL script to create an empty database on another SQL instance

& sqlcmd -S .SQLInstance -E -i c: empcreatemydb.sql

3) Generate a change script using the snapshot from step #1 and the empty database from step #2

& sqlcompare /force /scriptfile:c: empmydb.sql /snapshot1:c: empmydb.snp /server2:.SQLInstance /database2:mydb

4) If I run the script generated in step #3 in SSMS, it throws an error because it attempts to create a view that is dependent on a table that isn't created until later in the script.

Note, if I generate the snapshot using a database, there doesn't appear to be any dependency problems. For now, I'm going back to using our development database for the snapshot generation, but it would be nice to just generate the script from source control.

Sign In or Register to comment.