Create insert statements for existing data in tables from SQL Server Management Studio (SSMS)

At lot of us will have used the ‘Generate Scripts‘ functionality in SQL Server Management Studio (SSMS) to export schema creation scripts from a particular database.

We can also do the same for the data in our tables and have SSMS auto generate insert statements for rows in one or more tables in a database. This can be useful for copying things like lookup or static data from one DB to another. The steps required are shown below…

Right click on a DB name and select Tasks -> Generate Scripts

Skip the introduction page and select which tables you want insert statements to be scripted for…

Click ‘Advanced‘ on the Set Scripting Options page…

In the Advanced Scripting Options popup select ‘Data only‘ in the Types of data to script section…

Set how you want to save the scripts

SQL Server Management Studio (SSMS) will generate inserts similar to below…

Leave a Reply

Your email address will not be published.