Generate script in SQL Server 2005 with data

2019-04-08 12:29发布

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

4条回答
来,给爷笑一个
2楼-- · 2019-04-08 12:49

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!

查看更多
\"骚年 ilove
4楼-- · 2019-04-08 12:58

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.

查看更多
小情绪 Triste *
5楼-- · 2019-04-08 13:00

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.

查看更多
登录 后发表回答