简体   繁体   English

如何备份表数据,以便与升级SQL Server 2000一起移动 - > SQL Server 2008?

[英]How to backup table data only, for move with upgrade SQL Server 2000 --> SQL Server 2008?

We've upgraded a copy of our production databases (SQL Server 2000) to SQL Server 2008, and made a bunch of fixes & changes to stored procedures. 我们已将生产数据库(SQL Server 2000)的副本升级到SQL Server 2008,并对存储过程进行了大量修复和更改。 Now I want to copy the current data out of production (SQL Server 2000) and push it into the new SQL Server 2008, and point the production applications to the new one. 现在,我想将当前数据从生产中复制(SQL Server 2000)并将其推送到新的SQL Server 2008,并将生产应用程序指向新的应用程序。 All the table schemas are unchanged. 所有表模式都保持不变。

I know that scripting all the tables as inserts to a file is one possibility. 我知道将所有表脚本化为文件的插入是一种可能性。 Is this the best method? 这是最好的方法吗? Or are there better approaches? 还是有更好的方法? Are foreign keys going to be a problem? 外键是否会出问题?

Here are couple things you can do and all of these have advantages and disadvantages: 以下是您可以做的几件事,所有这些都有优点和缺点:

Manual scripting and linked servers: 手动脚本和链接服务器:

Setup linked server connections and use INSERT INTO 设置链接的服务器连接并使用INSERT INTO

INSERT INTO server2008.databaseName.schemaName.TableName (Col1, Col2, ..., Coln)
SELECT Col1, Col2, ..., Coln
FROM server2000.databaseName.schemaName.TableName

Mind the execution order of these. 注意这些的执行顺序。 Make sure to first migrate tables that have no references to avoid issues with foreign keys 确保首先迁移没有引用的表以避免出现外键问题

You can even temporary disable foreign keys and identity inserts on some tables 您甚至可以临时禁用某些表上的外键和标识插入

ALTER TABLE MyTable NOCHECK CONSTRAINT FK_Constraint
SET IDENTITY_INSERT tableName ON

-- INSERT STATEMENT HERE

SET IDENTITY_INSERT tableName OFF
ALTER TABLE MyTable CHECK CONSTRAINT FK_Constraint

Export Data Wizard 导出数据向导

Already suggested by Tomasito – just make sure to execute scripts in correct order. 已经由Tomasito建议 - 只需确保以正确的顺序执行脚本。 First scripts for tables with no references , than tables that only reference data in previously inserted tables and so on…. 没有引用的表的第一个脚本,而不是仅引用先前插入的表中的数据的表等等。

Third party tools 第三方工具

There are many of these that will do the job for you. 有很多这些将为你完成这项工作。 If this is a one-time task you can get the job done using trial version. 如果这是一次性任务,您可以使用试用版完成工作。 Couple I know are ApexSQL Data Diff, SQL Data Compare, AdeptSQL Diff. 我知道的几个是ApexSQL Data Diff,SQL Data Compare,AdeptSQL Diff。

In Microsoft SQL Server Management Studio right click on database and Import and Export options. 在Microsoft SQL Server Management Studio中右键单击数据库和ImportExport选项。 Another method is to use SQL Prompt: SQL Compare (paid tools). 另一种方法是使用SQL Prompt:SQL Compare(付费工具)。 You must try with your dataset and decide with option is better for you. 您必须尝试使用​​数据集,并选择更适合您的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM