views:

132

answers:

4

I have a typical dev scenario: I have a SQL 2008 database that I want to copy every so often to my local instance of 2008 Express so that I can do dev, make changes, etc. to the local copy. I have some constraints though: the source db is part of a live e-commerce site in shared hosting so I can't detach it and the hosting service wants me to pay $5 for each ad hoc back up I invoke.

What I'd like is some tool that I can invoke ad hoc to take a snapshot (complete, not incremental) of the live db that I can then import in my local one. I've tried the SSMS 2008 Copy Database Wizard but it gives me an error saying I can't do that with Express. I tried the Generate Scripts tool and thought that was going to make it - the export to my local disk worked but when I went to import using SQLCMD (the script was 1GB so SSMS errored when I tried to open it there), it told me there was a syntax error a few thousand lines in.

Coming from the MySQL world, this process is trivial. All I want is an analog of mysqldump and then a command-line way to import that file into a db. Surely there's an easy way to do this in the SQL Server world? This seems like the most basic use-case for developers.

[ Yes, I've seen a few other questions here that seem similar but I didn't think they had the same constraints. ]

A: 

Try SQL Dumper.

SQL Server Dumper enables you to dump selected SQL Server database tables into SQL INSERT statements, that are saved as local .sql files and contain all the data required to create a duplicate table, or to be used for backup purposes. You can choose to create an individual .sql file for each table, or combine all selected tables into a single file.

Davorin
But if he has some invalid data in there wouldn't SQL Dumper react the same way, throwing an error?
James Black
Maybe sql-dumper will generate better dump. He can give it a try.
Davorin
A: 

SQL Server Database Publishing Wizard and osql usually do the trick for me with large databases.

Bob
Hmmm, the publishing wizard project appears dead. When I tried to install it, it claims I need the 2005 Management Objects installed. I went to install the 2008 ones but that installer said I already had them installed. So I can't install this until they update it to know that 2008 exists.
DaveBurns
+1  A: 

If they don't charge you to run queries against the database these tools may help. Granted these are not free tools, but are handy on so many fronts it would be worth buying one. These tools can diff your source db and target db both data and structure or just one or the other, and optionally sync the target database to be just like the source.

http://www.innovartis.co.uk/ http://www.red-gate.com/products/sql%5Fdata%5Fcompare/index.htm

StarShip3000
In the end, I went with Red Gate's SQL Data Compare. I set up the project quickly, scripted it from the command line so I can set it up in Task Manager to run daily - problem solved. It's still a drag that SQL Server doesn't make this as easy as MySQL and that I had to spend money.
DaveBurns
+1  A: 

Best answer: full backup, restore, pay $5. Anything else seems to me like it'd waste a lot more than $5 worth of time.

onupdatecascade
Fair point and I've considered it. My ad hoc updates would probably be on the order of once a month or at most once every two weeks so the $5 is not a show-stopper. I guess I'm clinging to the scripting idea because it galls me that what seems like an obvious tool to have isn't there.
DaveBurns