Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

An AFTER INSERT trigger may not work correctly after you apply the fix documented in 975950


View products that this article applies to.

Symptoms

Consider the following scenario:
  • You have an instance of either SQL Server 2005 or SQL Server 2008 or SQL Server 2008 R2.
  • On this instance you apply the hotfix documented in the following KB article
    975950FIX: Error message when you run an SSIS 2005 or SSIS 2008 package that uses the IBM DB2 OLE DB provider to export data to an IBM DB2 server: "The number of failing rows exceeds the maximum specified. Out of memory"
In this scenario, if you have a SSIS package that inserts data into a table using ‘Table or View’ direct access mode, an AFTER INSERT trigger having an UNION clause and defined on the destination table may insert only one row instead of multiple rows.

↑ Back to the top


Cause

This occurs because SSIS incorrectly calls “SET ROWCOUNT 1” on the session that is executing the INSERT AFTER trigger. This causes the trigger to prematurely stop execution after it inserts the first row. 

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section of this article when you apply the fix documented in 975950. This hotfix is also included in the following updates:

  • 976951 Cumulative update package 7 for SQL Server 2005 Service Pack 3
  • 977444 Cumulative update package 9 for SQL Server 2008
  • 977443 Cumulative update package 6 for SQL Server 2008 Service Pack 1
  • 981355 Cumulative Update package 1 for SQL Server 2008 R2
So, the issue affects any builds of the respective product that contain this fix. You can use the following table as quick reference:
If you are on…Affected versionsAffected builds
SQL Server 2005 (SP3)(SQL 2005 SP3+CU7 for SP3) and later 9.00.4273 or later
SQL Server 2008 (RTM)(SQL Server 2008 + CU9 for SQL 2008) and later versions10.00.1828 or later
SQL Server 2008 (SP1)(SQL Server 2008 SP1+ CU6 for SP1) and later 10.00.2757 or later
SQL Server 2008 R2(SQL Server 2008 R2 + CU1 ) and later10.50.1702.0 or later




↑ Back to the top


Resolution

To workaround the problem do the following in the OLE DB Destination editor:
  • Use 'Table or view - fast load' option. 
  • In the Advanced Editor dialog box, go to the Component Properties tab and in the FastLoadOptions add the value 'FIRE_TRIGGERS'

For additional information refer to the following topic in SQL Server Books Online:


↑ Back to the top


More Information

Example: The following trigger uses UNION clause to inserts multiple rows in the destination table (MyTable) 

ALTER TRIGGER [dbo].[MyTrigger]
   ON  [dbo].[MyTable]
   AFTER INSERT AS
BEGIN
      SET NOCOUNT ON;
      INSERT INTO dbo.MyTable (x, y)
      SELECT 7 AS x, 7 AS y UNION
      SELECT 8 AS x, 8 AS y UNION
      SELECT 9 AS x, 9 AS y 
END
Because of the problem discussed in this article, when an SSIS package inserts any row into the table, the trigger only inserts the first row (7,7) and stops execution instead of inserting 3 rows.

↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 2508239
Revision : 3
Created on : 11/20/2019
Published on : 11/20/2019
Exists online : False
Views : 369