Generate script in SQL Server 2005 with data

23.9k Views Asked by At

How can I generate a script in SQL Server 2005 with data in table?

4

There are 4 best solutions below

0
On
0
On

Unfortunately the options to script data along with schema didn't seem to appear until SQL Server 2008, so I think you're stuck with third party options.

0
On

I had the same problem before, and there seems to be no direct script can be made to take all tables structures with their data.

I came around this situation by doing the following:

  1. Generate a script for database architecture (RightClick on Database > Tasks > Generate Scripts > Select all tables, and script to a file)
  2. Create a backup file for the database (RightClick on Database > Tasks > Backup)

Then, to take your database somewhere else:

  1. Execute the database script file to create tables
  2. Restore the database using [Database Name] > Restore > Database.

This worked just fine for me using SQL Server 2005.

2
On

Update

The answer below is not for SQL Server 2005 as @jake mentioned. So pls ignore the answer. I am keeping the answer, incase someone wanted to see how to do it on other SQL Server versions


Right click on the database. Then select the Tasks->Generate Scripts See the image here

Then, Select the table or tables which you need insert script to be generated. see the image here

Now Click next and click on Advanced and select "Types of data to script" see the image here

Finally, next, next, you get all your data in insert scripts. Good bye excel!