Red Gate forums :: View topic - Restore db from SSC from command line
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Source Control 3
SQL Source Control 3 forum

Restore db from SSC from command line

Search in SQL Source Control 3 forum
Post new topic   Reply to topic
Jump to:  
Author Message
kraades



Joined: 23 Oct 2012
Posts: 5

PostPosted: Fri Nov 30, 2012 10:45 am    Post subject: Restore db from SSC from command line Reply with quote

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
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6577

PostPosted: Mon Dec 03, 2012 4:27 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
david.proctor



Joined: 23 Nov 2012
Posts: 2

PostPosted: Tue Dec 04, 2012 2:16 pm    Post subject: Reply with quote

Like Brian says, your best option is probably to check the scripts out and run a command like the following:

Code:
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
Code:
/version1
switch. Using
Code:
/version1:HEAD
checks out the most recent copy of the database.

Code:
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/content/SQL_Source_Control/help/3.1/SSC_Source_Controlling_Data

Let me know if this is useful and if you need any more help.
_________________
David Proctor
Technical Author,
Red Gate Software
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group