Thursday, July 28, 2016

How To Export A Sql Table As A Series Of INSERT Commands in Sql Server 2012

Occasionally as developers we need to copy the contents of a database table to another remote sql server that we cannot access.  We can export an Excel spreadsheet and email that to our counter parts at the remote machine.  Another option is to create a file of SQL insert commands that will transfer the data. 
In Sql Server Management Studio right click on the database containing your table,
Select "Tasks/Generate Scripts"

 
 Skip the intro screen and then select the table to export
 

Click "Next"
 Then select "Advanced" and set "Types of data to script" to be "Schema and data" (or only "Data" depending on your needs).