13
votes

I need to copy an entire database from a SQL Server 2005 on my server over to my local SQL Express in order to run my application for a presentation. What is the fastest/easiest way to get this done?

EDIT: I have very limited access to my server so I don't think I can access the backup file that I could create so that is out.

7

7 Answers

11
votes

If the database is not too big, you could use the Database Publishing Wizard.

This is a free tool from Microsoft which creates a complete SQL script of a database for you (not only the tables and stuff, but all data as well).

You can install the tool on your machine, connect to a remote server and let the tool create the script directly on your machine.

You can download the Database Publishing Wizard here.


Apparently the link above doesn't work anymore in 2019.
That's probably because in newer versions of SQL Server Management Studio, the functionality of the Database Publishing Wizard is included out-of-the-box, so there's no need to install it separately.

It's now called the Generate and Publish Scripts Wizard, but it does exactly the same.

8
votes

You can right click the database -> Tasks -> Generate scripts. Here you can select one, multiple, or all objects. Then in the 'Set Scripting Options' step of the wizard, click Advanced. In here set the property 'Types of Data to script; to Schema and Data.

Having done these steps, make sure you publish to a file. Because only file can handle large amounts of data.

Now you should have all your objects, tables, and data scripted. Now start running the scripts and viola!

5
votes

Back up the database on the server and then restore it locally in SQL Express.

EDIT: If this is part of your work, surely you can get someone in networks to get you a backup..?

3
votes

If you can login to both servers (the Express and the 05 Server) using SQL Server Management Studio then you can do a DB Restore from one database to the other. No need for backup files at all.

2
votes

You can use SSIS's database copy wizard, but it's not quick at all. Is there a DBA there that you can ask for the backup file? That will probably turn out to be the fastest way.

2
votes

Depending which versions of SQL Server you are using, you might get some mileage out of the SQL Server Database Publishing Wizard from Microsoft. I've had mixed results with this tool in complex environments, but for most simple database scenarios it is a great tool.

An example of a scenario where I ran into difficulties was a DB with multiple distinct schemas, each with their own owner and extreme separation between the tables (don't ask...). As I said, though, most other scenarios have been fine.

2
votes

Save your database as a sql script

EMS SQL Manager (for example) allows you to backup your database as a script in a .sql file. It is then possible to run this file against any other SQL server. Just update the first line of the script (CREATE DATABASE ....).

You can even fully parameter the script in order to include data from complete or filtered tables.