Article ID: 961451 - Last Review: August 25, 2009 - Revision: 2.0
FIX: You receive an incorrect value when you query the last-inserted identity value after you use a client-side cursor to insert data to a table that contains an identity column in an application that uses ActiveX Data Objects
In an instance of Microsoft SQL Server, you have two tables, and each table contains an identity column.
You create an INSERT trigger on the first table. The trigger inserts data to the second table when the trigger executes.
You have an application that uses Microsoft ActiveX Data Objects (ADO) to connect to the instance of SQL Server.
In the application, you use a client-side cursor to insert data to the first table.
In this scenario, when you run the application and then query the last-inserted identity value, you may find that the function returns an incorrect value. The value corresponds to the auto-increment value that is generated on the second table instead of on the first table.
This problem occurs in the Microsoft Data Access Components (MDAC) 2.8. You may have MDAC 2.8 installed on one of the following Windows operating systems:
When data is inserted in the first table, the insert trigger uses the @@IDENTITY function instead of the SCOPE_IDENTITY function to obtain the last-inserted identity value. Therefore, the @@IDENTITY function may return an identity value that is not generated by the same table.
A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing the problem described in this article. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.
If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.
Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:
Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.
Prerequisites
You must have the corresponding service pack installed before you apply this hotfix.
Restart information
You do not have to restart the computer after you apply this hotfix.
Registry information
You do not have to change the registry.
Hotfix file information
This hotfix contains only those files that are required to correct the issues that this article lists. This hotfix may not contain of all the files that you must have to fully update a product to the latest build.
The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
Note The fix does not change the behavior of ADO through Microsoft OLE DB provider for ODBC (MSDASQL)..
For more information about the naming schema for SQL Server updates, click the following article number to view the article in the Microsoft Knowledge Base:
822499
(http://support.microsoft.com/kb/822499/
)
New naming schema for Microsoft SQL Server software update packages
For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684
(http://support.microsoft.com/kb/824684/
)
Description of the standard terminology that is used to describe Microsoft software updates