How to export MSSQL Table as an insert script

How to export MSSQL Table as an insert script

This is very common scenario on a daily basis for Database administrator, but doing this in Microsoft SQL Server is not as straight forward as you might think.

To keep this tutorial as simple and strait forward that even a N00B can follow along, just “Follow The Yellow Click Road…”

First:
Right click on the database where the table for exporting is, and choose Tasks -> Generate Scrip ts

How to export MSSQL Table as an insert script

Step No.2: Next on the Dialog with additional settings it contains some screens for gathering information about the script that is about to be generated. Click Next

How to export MSSQL Table as an insert script

Step No.3: On this selection Click: Select Specific Database Objects, and select the table that you want to export script for. Then Click Next.

How to export MSSQL Table as an insert script

Step No.4: This is third prompt you should choose the file name for exporting, encoding options, and also what you want in that table to be exported. Now Click the Advanced button, and from those options scroll down to “Types of data to script”, and Click the arrow for the dropdown to click on “Data Only”. Click OK to close Advanced Scripting Options, and then go to the next screen of Generate and Publish Scripts dialog.

How to export MSSQL Table as an insert script

Step No.5: We have two more dialog screens left but with nothing to set on them. Just to preview selected options and to see the status of the generated scrip t. Click Next and Finish to close the dialog.

Generate and Publish Scripts dialog

Generate and Publish Scripts dialog

How to export MSSQL Table as an insert script - Generate and Publish Scripts dialog

This is how the result should look like if you try to open the file where the script was generated.

How to export MSSQL Table as an insert script

This concludes how to export MSSQL Table as an insert script

Posted in MSSQL, SQL, Tutorials and tagged .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.