Articles → SQL SERVER → Generate Script For Database Objects Using SSMS
Generate Script For Database Objects Using SSMS
Database Schema
Steps
- Right-click on the database, and go to "Tasks" → "Generate Scripts…"
- Following window appears on click of "Generate Scripts…"
- Click on "Next" button
- Following window will appear
- Click on the "Next" button.
- Following window will appear
- Save the generated script as a file
- Copy it on the clipboard
- Show it in the new query window
- Now, click on the "Next" button, and the following window will appear
- Click Next and scripts will be generated for the database objects as shown in figure below
- Click on Finish to complete the process. A script file will be created on specified path
- 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
- 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
- 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