How can I generate a script in SQL Server 2005 with data in table?
问题:
回答1:
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.
- SSMS Tool Pack has a generate inserts option
- Narayana Vyas Kondreddi has an excellent generate inserts script I've been using for a few years now
回答2:
Use data publishing wizard.
step by step explanation at :
http://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/
回答3:
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:
- Generate a script for database architecture (RightClick on Database > Tasks > Generate Scripts > Select all tables, and script to a file)
- Create a backup file for the database (RightClick on Database > Tasks > Backup)
Then, to take your database somewhere else:
- Execute the database script file to create tables
- Restore the database using [Database Name] > Restore > Database.
This worked just fine for me using SQL Server 2005.
回答4:
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!