Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 952111 - Last Review: May 5, 2008 - Revision: 1.1
The identity column of the destination table does not contain the same identity values as the source table after you use SQL Server Management Studio to import data or to export data in Microsoft SQL Server 2005
Consider the following scenario:
- In Microsoft SQL Server 2005, you use SQL Server Management Studio to import data or to export data from a source table to a destination table.
- Both the source table and the destination table include an identity column.
- You enable the Enable identity insert option for the source table.
- In the SQL Server Import and Export Wizard, you enable the Optimize for many tables option.
In this scenario, after you finish importing or exporting the data, you find that the identity column of the destination table does not contain the same identity values as the source table. Instead, the identity column of the destination table contains resequenced identity values.
Note This problem does not occur in Microsoft SQL Server 2000.
This problem occurs because the SQL Server Import and Export Wizard does not set the IDENTITY_INSERT property for the table if the
Optimize for many tables option is enabled. The IDENTITY_INSERT property can be set for only one table at a time. If you enable the
Optimize for many tables option in the wizard, the copy operation is performed for several tables on several threads at the same time. Therefore, the SQL Server Import and Export Wizard does not set the IDENTITY_INSERT property.
To resolve this problem, do not enable the
Optimize for many tables option in the SQL Server Import and Export Wizard.
If you do not enable the
Optimize for many tables option, the data operation may take a longer time to finish. If you want to preserve the identity values when you import or export a large amount of data, we recommend that you use one of the following methods:
If you enable the
Enable identity insert option for the source table, the SQL Server Import and Export Wizard should execute the SET IDENTITY_INSERT ON statement for each table that contains an identity column. Then, after the identity values are inserted to the destination table, the SQL Server Import and Export Wizard should execute the SET IDENTITY_INSERT OFF statement. However, these operations do not occur correctly if the
Optimize for many tables option is enabled.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
APPLIES TO
- Microsoft SQL Server 2005 Standard Edition
- Microsoft SQL Server 2005 Developer Edition
- Microsoft SQL Server 2005 Enterprise Edition
- Microsoft SQL Server 2005 Standard X64 Edition
- Microsoft SQL Server 2005 Enterprise X64 Edition
- Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems
- Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems
| kbtshoot kbexpertiseadvanced kbsql2005tool kbprb KB952111 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate