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:


Step 2:

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


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.


Step 4: Click Next


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.


Step 6: Click Next and then Finish,


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


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.