Wednesday, July 29, 2009

.sql script to export, transfer or copy SQL Server 2008 database




A common task for developers is to copy a database, with its schema, with or without its data, over to a new database. For example, if you own a small website and have a shared hosting provider, you'll want to get your database from your machine to their server.
Oftentimes there are many solutions to a problem and we want the simplest here. SQL Server 2008 has a surprisingly simple solution if it's not immediately obvious at first.

  1. open up SQL Server 2008 Management Studio
  2. right click on your database
  3. context menu appears, navigate to Tasks, then "Generate scripts..."
  4. you get a wizard which brings you to a window with the following options:


the only option worth noting is to set "Script Data" to true if you want to copy data with the schema.

The rest is self-explanatory because, well it's a wizard, but now you at least know that this tool exists.

No comments:

Post a Comment