mysqldump equivalent for SQL Server

The easiest way is the sql server database publishing wizard.

  • Open source
  • Free
  • Does exactly what you want
  • Developed by microsoft

It does not have all the features of mysqldump but it is close enough.

http://www.codeplex.com/sqlhost/wiki/view.aspx?title=database%20publishing%20wizard


To do this really easily with SQL Server 2008 Management Studio:

1.) Right click on the database (not the table) and select Tasks -> Generate Scripts

location of tool

2.) Click Next on the first page

3.) If you want to copy the whole database, just click next. If you want to copy specific tables, click on "Select Specific Database Objects", select the tables you want, and then click next.

4.) "Save to File" should be selected. IMPORTANT: Click the Advanced button next to "Save to File", find "Types of data to script", and change "Schema only" to "Schema and data" (if you want to create the table) or "Data only" (if you're copying data to an existing table).

adding data to the script

5.) Click through the rest and you're done! It will save as a .sql file.


Not finding the right tool, I decided to create my own: a sqlserverdump command line utility. Check it out on github.


The easiest way to move a Database would be to use SQL Server Management Studio to Export the database to another server, or if that doesn't work, make a backup like other's had suggested and restore it elsewhere.

If you are looking for a way to dump the table structure to SQL as well as create insert scripts for the data a good free option would be to use amScript and amInsert from http://www.asql.biz/en/Download2005.aspx.

If you want a good pay version I would check out Red-Gate SQL Compare and Red-Gate SQL-Data Compare. These tools are probably overkill though and probably a bit pricey if you don't intend to use them a lot. I would think it would mostly be relegated to DBAs. You can look at the Red-Gate tools at http://www.red-gate.com/.