How to generate SQL table script with data

In this article we’ll learn how to generate SQL table script with data. You can create insert script of table before playing with its data for the safer side so that if something went wrong then data can be restored using insert script. Moreover, sometime for some troubleshooting we need to share the insert script of some specific table with dev or client. So, one must know how to create this using SQL Server. Ways of creating insert script is same in all versions of SQL server.

Step-1: right click on DB name and select “Tasks” and then “Generate Scripts” as shown in below image.

How to generate SQL table script with data

 

Step-2:  Next following screen will appear, simply click next on this screen.

How to generate SQL table script with data

Step-3: Next, below screen will appear where you can select the table name or stored procedure name whose script you want and Click NEXT.

Step-4: In below screen please select “Open in new query window” and then click on ‘Advanced’ button.

How to generate SQL table script with data

Step-5: On next screen you’ll get three options (detail given below) as shown below. You need to choose “Data only” as we need insert script of existing table. Please click OK after selection of right option.    

  • Data only – it will create insert script of data only.
  • Schema and data– it will generate “create table” script along with “insert data” script.
  • Schema only- – it will generate “create table” script only.

Step-6: On click of next below screen will appear where you can verify Server & DB name and table whose insert script you want.

How to generate SQL table script with data

Step-7: On click of next, a new window will open which will contain the INSERT script as shown below.  

How to generate SQL table script with data

I hope you enjoyed reading this article. In this article you learned about how to generate SQL table script with data. You can learn more SQL concepts on Microsoft Learn.

For more knowledge of MS SQL, you can check this section HERE

You may also like:

Posted in SQL

Leave a Reply

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