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.

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

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.

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.

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

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:
- SQL server Column Encryption using symmetric key.
- How to Update using Select statement in SQL Server.
- SQL Server Interview Questions and Answers.
- Import One Database to another in SQL server.
- Generate database scripts in SQL server.
- Different ways to search SQL objects in database.
- SQL CASE statement
- SQL IIF function
- QUOTENAME function in SQL
- How to Take SQL Server Database Offline/Online
- How to use SQL ORDER BY in Your Queries
- SQL Paging using OFFSET and FETCH
- Fill Factor in SQL Server
- How to Search SQL Object in Complete Database
- How to generate SQL table script with data