SQL Server 2008 R2 Generate Scripts Wizard with Database Schema and Data

11:25

Follow The Below Steps:

1. Connect to SQL Server Instance using SQL Server Management Studio. Then right click on the AdventureWorks database which in this example we want to script out. From the popup menu, select "Tasks" and then "Generate Scripts…" option as shown in the snippet below.



2. In Generate and Publish Scripts wizard screen; click Next to continue with the wizard.
3. In the Choose Objects wizard screen; Select “Script entire database and all database objects” option and click Next to continue with the wizard.
4. In the Set Scripting Options wizard screen; choose the output type as “Save scripts to a specific location” and specify the path where you would like to save the database script file which will be generated by the wizard. Click the Advanced button which is highlighted in the snippet below for specifying the schema and data scripting option.
5. In Advanced Scripting Options screen; choose the option Schema and data for the Types of data to script option and click OK to save the changes and to return to Set Scripting Options wizard screen.
a) Data only – If this option is selected, it will only script out data within the tables b) Schema and data – If this option is selected, it will script out Schema as well as the data within the selected objects c) Schema only – If this option is selected, it will script out the Schema only
6. In the Summary wizard screen; you will be able to see a quick summary of all the options which you have selected so far. Click Next to confirm and generate the scripts.
7. In Save or Publish Scripts wizard screen; you will be able to see a Success or Failure message against each object for which the script was requested to be generated. Finally, click Finish to close the wizard.
8. In case the generated scripts files are too large to open in SQL Server Management Studio, you can utilize the SQLCMD Utility to execute the scripts.
9. In the SQLCMD Utility type the below line and hit enter for the schema and data to get loaded to the destination database.
10. You will be able to see the below snippet once the schema and data is successfully loaded to the destination database.

Conclusion

Hope this will helpful to you.

You Might Also Like

0 comments