Generate Insert Scripts for a Table in SQL Server

This feature helps us to export data of a table from one database to other. Let’s open SSMS, select a database and click on Generate Scripts under Tasks as shown below:

Step 1:

task

Step 2:

Click on Next, It opens a wizard for selecting database objects like tables and views which scripts need to be generated.

wizard

Step 3:

We can select the entire database or specific database objects for which scripts has to be generated. We will go with option 2 (Select specific database objects) and select Employeestable.

Employeestable

Step 4: Click Next

nexr

Step 5:

Click on Advanced and set “Type of data to script” to “Schema and data,” Selecting this option will generate scripts for table creation as well INSERT scripts to export its data. We can save generated scripts in a clipboard or a file or new Query window. Let’s go with the new Query window option.

option

Step 6: Click Next and then Finish,

finish

It will open a new query window witthe below INSERT scripts:

code

By using this feature, we can easily export schema and data of a database\tables. I am ending things here. I hope this article will be helpful for all.