KentZhou
KentZhou

Reputation: 25573

how to generate sql for existing data in a table?

Suppose I have a table with data like:

Tab(id, name)
1, 'Name 1'
2, 'Name 2'
3, 'Name 3'

In SQL Server management studio, I can generate script to create this table(ddl). But I also want generate sql for data like:

insert into Tab(id, name) values(1, 'Name 1');
insert into Tab(id, name) values(2, 'Name 2');
insert into Tab(id, name) values(3, 'Name 3');

How to generate above insert sql with data for a table?

Upvotes: 1

Views: 388

Answers (2)

Haedrian
Haedrian

Reputation: 4328

Under Tasks > Generate scripts you can hit 'Advanced'

One of the choices is "Types of Data to Script" which is set by default as Schema only.

Go for "Data and Schema" and that's it.

Upvotes: 2

Related Questions