Restore db from SSC from command line

kraadeskraades Posts: 9
At the moment we restore our test database from a SQL backup file.

We would like to store the test database (schema and data) in TFS using SSC and restore it using the command line or using an API.

What are the possibilities?

Current:
SQL backup file --> SQL database

Requirement:
SSC --> SQL backup file --> SQL database
or if this is not possible:
SSC --> SQL database

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    You can use SQL Compare to check out the database scripts from TFS and create a new test database from that.

    Before that can happen, though, you'll probably want to use SQL Source Control to get the database *into* TFS as a set of SQL scripts.
  • Like Brian says, your best option is probably to check the scripts out and run a command like the following:
    SQLCompare.exe /scripts1:"C:\ScriptsFolder" /s2:targetserver /db2:targetdatabase /include:staticdata /sync
    

    However, you can also get SQL Compare to check it out of SQL Source Control for you using the
    /version1
    
    switch. Using
    /version1:HEAD
    
    checks out the most recent copy of the database.
    SQLCompare.exe /s1:sourceserver /db1:SourceDatabase /version1:HEAD /s2:targetserver /db2:targetdatabase /include:staticdata /sync
    

    Just to be clear, it doesn't actually compare against the source database, it compares against the scripts folder of the source database that it checks out.

    To store the data as well as the schema you'll want to make sure you've linked all the tables as static data. More about this is here: http://www.red-gate.com/supportcenter/c ... lling_Data

    Let me know if this is useful and if you need any more help.
    David Proctor
    Technical Author,
    Red Gate Software
Sign In or Register to comment.