Diff script using sql compare command line

ax4413ax4413 Posts: 7
edited December 3, 2013 10:16AM in SQL Compare Previous Versions
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.

Comments

  • 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
    Product Manager
    Redgate Software
  • 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
  • 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.
  • 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
    Product Manager
    Redgate Software
Sign In or Register to comment.