Close

Generate SQL Create and Insert script

Today I came across a SQL feature I had been looking for a long time: creating a table create script including the data that are inside that table. If you right-click the table, you can only get a table create script. If you click the database instead, you can select context menu Generate Scripts.
In the wizard that appears, click option ‘select specific data objects’ and select the table you want to generate create and insert scripts for. Next leave Save to File selected and click Advanced. Change option ‘Type of data to script’ to ‘Schema and Data’. Click [Next] and generate the sql file.

Gotcha. If this functionality doesn’t work, restart SQL Server and reconnect to the database. For some reason, Generate Script only worked after restarting SQL.