BUG: SQL-DMO BulkCopy Object IncludeIdentityValues Property Fail

Last reviewed: October 9, 1997
Article ID: Q167867
The information in this article applies to:
  • Microsoft SQL Server, version 6.5
BUG #: 1319 (Starfighter65)

SYMPTOMS

When inserting into a SQL Server table using the SQL Server Distributed Management Object's (SQL-DMO's) BulkCopy object, automatically incremented values are inserted into the table's identity column based on the identity column's seed. The values in the source file are not inserted into the identity column. This occurs even when BulkCopy's IncludeIdentityValues property is set to True.

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The BulkCopy object's IncludeIdentityValues property activates IDENTITY_INSERT so that a source file's values that map to an identity column in the destination table can be explicitly inserted into the identity column of a table. Records import properly, but the literal values in the source file are not inserted into the identity column; rather, new, incremented values, based on the initial property column's seed, are inserted.

SQLTrace reveals that IncludeIdentityValues property runs a SET IDENTITY_INSERT <tablename> ON in a different connection to SQL Server than the connection that runs the ImportData method. The SET command only applies to the current batch or connection.

For example, suppose you have a table with an identity column called Id, whose seed is 1, and a char column called MyChar:

   Id   MyChar
   --   ------

   1     A
   2     B

Setting the IncludeIdentityValues to True should import the following data

   Id   MyChar
   --   ----

   100   H
   101   I

into the SQL table like so:

   Id   MyChar
   --   ------

   1     A
   2     B
   100   H
   101   I

However, it fails to work properly, and actually inserts the data as:

   Id   MyChar
   --   ------

   1     A
   2     B
   3     H
   4     I

REFERENCES

For more information about the BulkCopy object's IncludeIdentityValues property, query on "IncludeIdentityValues" in SQL Server Books Online.

For sample code using the BulkCopy object, see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q152801
   TITLE     : INF: Examples of Sp_OA Procedure Use and SQLOLE.Transfer
               Object


Additional query words: error message DMO
Keywords : kbbug6.50 SSrvAdmin SSrvDMO SSrvErr_Log SSrvGen kbenv kbhw
Version : 6.5
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbpending


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 9, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.