Schemas in SVN / Compare with Server

  • I have a process set up where the database schema is scripted out to .sql files. Is there any way I can compare this to the actual server to make sure our Source Control is in line with the server and vice versa?

  • Let's say you already have a project folder called \MyDatabase, which is working folder for SVN. Using your tool, script your database out to another project folder called \MyDatabase2, and then use a folder/file comparison tool like WinMerge to compare differences in scripts between the two folders.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Redgate software makes a tool called SQL Compare that will compare between SVN (TFS, Git, etc.) directly and your database, or a set of .SQL files and the database (or a backup and the database or even just two databases). That's how I'd recommend getting this done.

    DISCLAIMER: I work for Redgate.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Will try this idea! Thanks.

  • nick.latocha (2/23/2016)


    I have a process set up where the database schema is scripted out to .sql files. Is there any way I can compare this to the actual server to make sure our Source Control is in line with the server and vice versa?

    I used something like that: https://gist.github.com/cheynewallace/9558179

    Very easy way, just start a power Shell script. If you have any source control tool, you spool it to that folder and you see the differences straight away. It uses the SQL server builded in stored procedures, which are also used when you click "generate script" in SS Management Studio.

    Hope this helps

    ------------------------------------------------------------------------------------------------------------------------------------------------
    Im working as a Business Intelligence Specialist and mainly with Microsoft BI and data warehousing but also with Oracle Databases. I like working with the data and it is my passion to get more out of the data.

  • Thanks! Useful script!

  • Hi

    We user Red Gate tools (Compare and Data Compare) and Powershell scheduled to run everyday using Windows Task Scheduler.

    Just a quick overview of the process:

    - We use Powershell to download the files from TFS (trunk project folder) to a directory

    - Using Powershell and a RedGate Project File we compare a Production database (in a daily restore environment) to the directory

    - If there are discrepancies we email the Red Gate HTML report to the DBA Admins.

    Same goes for Data Compares however we only compare tables that hold static data items which are source controlled.

    Hope this helps...

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply