Generate Database Script with its Objects | SansSQL

Wednesday, January 12, 2011

Generate Database Script with its Objects

Generating the database script with its objects is one of the common tasks that a DBA would perform very frequently. This task may be carried out for various reasons like keeping the databases identical between environments and etc.

The process of scripting the database is simple and here is how to do this.
  1. Right-Click on the database which you choose to script out.
  2. Go to "Tasks" and choose "Generate Scripts"


  3. Now in the Script wizard, you will see the database that you want to script will be highlighted and there will be a check-box which "Script all objects in the selected database". If you select this check-box, then the wizard will script all the objects that are present in that particular database.
  4. After selecting the appropriate option click "Next" and now in the "Choose Script Options" page, select the option that you want to include in the script.
    From SQL Server 2008 onwards, you can choose to script the data also if needed. So to script the data, go to the "Table/View Options" in the "Choose Script Options" page and change the "Script Data" option to "True"


  5. If you have not choose the option to script all objects from step 3 then after clicking next, the wizard will ask you what type of objects it want to script. Select the object types and click "Next".
  6. Choose the objects that you want to script and click "Next".

  7. Now in the "Output Option" page, select how you want to store the output of this process and click "Next"
  8. Now the wizard will summarize on what actions it will perform. If you are satisfied with the action then click "Finish" else go back and change accordingly.




    This article is also available in pdf format for downloading.
    Please Click here to get your copy.

Ads