Diff script using sql compare command line

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

Diff script using sql compare command line

Postby ax4413 » Tue Dec 03, 2013 10:20 am

Is it possible to create a diff script using sql compare command line?

I want to create a upgrade script using sql compare command line for use in our CI process. I cant seem to get it to work. Are there any examples of how to do this. It only seems possible to use the \\synchronize switch. This is not what i want to do, I want to generate scripts that can be run.

I am presently evaluating the tools and this will be a deal breaker for us if we cant generate scripts..

Any help would be greatly appreciated.
ax4413
 
Posts: 5
Joined: Tue Dec 03, 2013 10:14 am

Postby David Atkinson » Tue Dec 03, 2013 10:51 am

I think you're looking for /ScriptFile

sqlcompare /db1:WidgetStaging /db2:WidgetProduction
/scriptFile: \"C:\\Scripts Folder\\WidgetSyncScript.sql\"

It's described in more detail here:

http://www.red-gate.com/supportcenter/C ... _in_the_cl
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Postby ax4413 » Tue Dec 03, 2013 11:31 am

Thank you David Atkinson,

I had previously been trying to use the /MakeScripts switch which was wrong, all i need to do was use the /ScriptFile switch.

Can I ask one other question?

This is a question to do with migration scripts. I am using the below command, but this does not seem to be picking up the migration scripts that I have generated.

sqlcompare.exe
/include=\"Identical\"
/include=\"StaticData\"
/scripts1=\"C:\\SVN\\Code\\trunk\\Databases\\Test1\\Database\"
/migrationsfolder:\"C:\\SVN\\Code\\trunk\\Databases\\Test1\\DatabaseMigration\"
/scriptsfolderxml:\"C:\\SVN\\RedgateBuild\"
/db2:Target
/scriptFile:\"C:\\SVN\\Output\\DiffScript.sql\"


Scripts1 is the location of my database source control
MigrationsFolder is the location of the migrations folder associated with source control
ScriptsFolderXML is a folder I created which contains a xml file I generated following your advice in post http://www.red-gate.com/MessageBoard/viewtopic.php?t=14941

Can you offer any advice?
I can create a new post if that helps.

Thanks in advance
ax4413
 
Posts: 5
Joined: Tue Dec 03, 2013 10:14 am

Closed

Postby ax4413 » Tue Dec 03, 2013 4:06 pm

I have resolved the issue my self. I use the following command.

sqlcompare.exe
/include=\"Identical\"
/include=\"StaticData\"
/sourcecontrol1
/revision1:HEAD
/scriptsfolderxml:\"C:\\ScriptFolderLocation.xml\"
/migrationfolderxml:\"C:\\MigrationFolderLocation.xml\"
/server2=\"localhost\"
/database2=\"Target\"
/scriptFile:\"C:\\SVN\\Output\\Diff.sql\"
/verbose

Where scriptsfolderxml points to an xml file path which defines the script folder. see below:

<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?>
<ISOCCompareLocation version=\"1\" type=\"SvnLocation\">
<RepositoryUrl>file:///C:/SVN/SVNRepository/trunk/Databases/Test1/Database/</RepositoryUrl>
</ISOCCompareLocation>

Where migrationfolderxml points to an xml file path which defines the script folder. see below:

<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?>
<ISOCCompareLocation version=\"1\" type=\"SvnLocation\">
<RepositoryUrl>file:///C:/SVN/SVNRepository/trunk/Databases/Test1/DatabaseMigration/</RepositoryUrl>
</ISOCCompareLocation>

These files were generated by myself, they do not exist as part of source control.

Hope this helps someone else.
ax4413
 
Posts: 5
Joined: Tue Dec 03, 2013 10:14 am

Postby David Atkinson » Tue Dec 03, 2013 4:16 pm

We are moving towards an improved migration script approach, which you might want to take a look at:

http://www.red-gate.com/products/sql-de ... tions-beta

This doesn't rely on the command line being able to talk back to your version control system at compare time, so is more robust generally. Would you be able to take a look and see if works for you?
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase


Return to SQL Compare 10

Who is online

Users browsing this forum: No registered users and 2 guests