Articles → SQL SERVER → Generate Script For Database Objects Using SSMS
Generate Script For Database Objects Using SSMS
Database Schema
Click to Enlarge
Steps
- Right click on the database, and go to "Tasks" → "Generate Scripts…"
Click to Enlarge
- Following window appears on click of "Generate Scripts…".
Click to Enlarge
- Click on "Next" button.
- Following window will appear.
Click to Enlarge
- Click on the "Next" button.
- Following window will appear
Click to Enlarge
- Save the generated script as file
- Copy it on clipboard
- Show it in new query window.
- Now, click on the "Next" button and following window will appear.
Click to Enlarge
- Click Next and scripts will be generated for the database objects as shown in figure below
Click to Enlarge
- Click on Finish to complete the process. A script file will be created on specified path
Click to Enlarge
Click to Enlarge
- Script Drop and Create – There are three options
- Create – When you want to generate ‘create’ script only for database objects
- Drop – When you want to generate ‘drop’ script only for database objects.
- Drop and Create – When you want to generate ‘drop and create’ script for database objects.
Click to Enlarge
- Types of data to script – There are three options
- Data only – When you only want to generate scripts for data only. This option is only valid for tables.
- Schema and Data – When you want to generate scripts for schema of data objects and data of tables.
- Schema only – When you want to generate scripts for schema only.
Click to Enlarge
- Script Indexes – It means while generating the script for tables, you also want to create a script for indexes as well then you can select this option to true.
Click to Enlarge