tags:

views:

113

answers:

4

I have been developing in VB.NET and SQL Server 2008 for a while now, but haven't got into live installs yet. In the database system I used be on it had the ability to archive multiple tables into a .dga file, as it was called. I could then restore the .dga file into another database or on another server.

I'm looking for the easiest way to accomplish something similar in SQL Server.

+1  A: 

If you want to move tabless without data, the simpliest thing is to script the tables you want and run the script.

We script all our db changes and commit them to subversion and then run them as part of the deplyment process.

If you want to put the whole database on prod including data (scrub out test records first!), then do a backup and restore onthe other server.

For future changes, wescript all our db changes and commit them to subversion and then run them as part of the deployment process. There also are tools that look at the structural differnces bewteen the two servers and creates scripts. REd-Gate's SQL Compare is really good for this.

HLGEM
Sorry, I should have been more specific. I am trying to transfer the data; I don't care about the table design, although it could come with it.
Jeff Stock
It would be really nice if I could somehow generate a script with all the INSERTS for every row of data. That way I could just run that script from the other server and change the database if need be and it would add the data on that server.
Jeff Stock
IF you want scripts to compare and move data, look at SQL DataCompare by red-gate as well. be aware though that the data you want to move from dev to prod is usually limited to lookup tables.
HLGEM
+3  A: 

If you want to transfer specific tables, then using Data Transformation Services (right click on the database in SQL Server Management studio and select "Import Data" and it will bring the dialog up for it). Of course, this assumes that you have both databases available to you.

If you are comfortable with replacing the database as a whole, you can easily backup the database and then restore it into a new one through SQL Server Management studio (or through calling the appropriate SP).

casperOne
Note that DTS has been replaced by SSIS as of SQL Server 2005
ahockley
This works great if, like you said, you have both databases available to you, but in most cases I don't.
Jeff Stock
A: 

In addition to HLGEM's suggestions, you can look into SSIS if this is an ongoing process.

Tom H.
+1  A: 

I would go for one of the following :

  • From MS SQL Management Studio, right click on the database / Tasks / Generate scripts

  • From Visual Studio, in the Server Explorer tab, "publish to provider"

Both will launch a wizard allowing you to export the tables you want the way you want (including data or not, creation scripts or not, etc etc.)

Brann