Scripting out the Schema & Data in SQL Server 2008

SQL Server 2008 has a neat feature that allows you to script out an object. Not really ground breaking so far. However, where this differs from SQL 2005 is that you can script out:

  • the schema
  • the data
  • the schema & data

You would think this option is available to you by right clicking directly on the object (typically a table for scripting out data and schema) but it isn't - you have to start on the database.

Right click on your database and select Tasks >Generate Scripts...

Step _One _Generate _Scripts

This will fire up a wizard to generate the scripts for you. 

Click Next and you will be prompted to select the objects you want to script out. I am going to choose one table for this purpose as it's easier.

Step _Two _Select _Object

Click Next

This is the important part, by default SSMS defaults to Schema Only to amend this to include the data you need to click Advanced

Step _Three _Click Advanced

Now scroll down to the proprty named Types of data to script and select an option from the drop down.

Step _four _type _of _data

Click OK and follow the rest of the wizard.

And there you have it, a simple way to script out your schema and data via SSMS 2008.

 

Note: If you are on SQL Server 2005 then I would recommend using an add-on such as SSMS Tools Pack as it includes this type of functionality which isn't available pre SQL 2008.

Posted by codingbadger at 13:05

0 Comments:

Post a comment

blog comments powered by Disqus

Authors

Recent Comments

Powered by Disqus