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

Article ID: 2508239 - View products that this article applies to.
Expand all | Collapse all

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
    975950 FIX: 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.

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. 

STATUS

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:
Collapse this tableExpand this table
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




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:


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.
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Properties

Article ID: 2508239 - Last Review: March 19, 2011 - Revision: 1.0
APPLIES TO
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Enterprise X64 Edition
  • Microsoft SQL Server 2005 Evaluation Edition
  • Microsoft SQL Server 2005 Express Edition
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Standard X64 Edition
  • Microsoft SQL Server 2005 Workgroup Edition
  • Microsoft SQL Server 2008 Developer
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 Enterprise Evaluation
  • Microsoft SQL Server 2008 Express
  • Microsoft SQL Server 2008 Express with Advanced Services
  • Microsoft SQL Server 2008 R2 Datacenter
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Enterprise
  • Microsoft SQL Server 2008 R2 Express
  • Microsoft SQL Server 2008 R2 Express with Advanced Services
  • Microsoft SQL Server 2008 R2 Standard
  • Microsoft SQL Server 2008 R2 Standard Edition for Small Business
  • Microsoft SQL Server 2008 R2 Workgroup
  • Microsoft SQL Server 2008 Standard
  • Microsoft SQL Server 2008 Standard Edition for Small Business
  • Microsoft SQL Server 2008 Workgroup
Keywords: 
KB2508239

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com