Over a million developers have joined DZone.

Generate Database Scripts With Data In SQL Server

DZone's Guide to

Generate Database Scripts With Data In SQL Server

How to generate SQL Server scripts of a database with existing data. The script will then give you an the insert query with other queries to integrate data into a new database.

· Database Zone
Free Resource

Traditional relational databases weren’t designed for today’s customers. Learn about the world’s first NoSQL Engagement Database purpose-built for the new era of customer experience.

In this post we will discuss about how we can generate SQL Server scripts of our database with existing data, once we generate the script, the result will give you an insert query with other queries, so that the data also will get inserted in your new database. We are going to use the option ‘Schema and data’ in SQL server for this task. I hope the screen shots given will help you generate the script with insert queries.


I was working on an article that has so many database transactions/actions. So I thought of attaching the database scripts with data in the source code download section of the article, so that it may help user to insert the data in his/her database. That made me to write this article. I hope you will like this.

Steps to Generate Database Scripts With Data In SQL Server

Step 1

Right click on your database and select Task -> generate script.

Image title


Step 2

Click next in the introduction screen.

Image title


Step 3

Select the database object which you are all you need and then click next.

Image title


Step 4

Now you will be shown a window which asks you about how your script should be published.

Image title


Click advanced in that window.

Step 5

Select ‘Schema and data’ from type of data to script option and then click OK.

Image title


Click next.

Step 6

Click finish, now check the script file, it must be having the insert queries too.

Image title


Now what else is pending, go ahead and run your script.


Did I miss anything that you may think which is needed? Have you ever wanted to do this requirement? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.

Your Turn. What Do You Think?

A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.

Learn how the world’s first NoSQL Engagement Database delivers unparalleled performance at any scale for customer experience innovation that never ends.

sql server ,script ,data

Published at DZone with permission of Sibeesh Venu, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}