FIX: An access violation occurs when you execute update query on a table that has a DML trigger in SQL Server

Applies to: SQL Server 2008 R2 Service Pack 2SQL Server 2008 R2 DeveloperSQL Server 2008 R2 Enterprise

Symptoms


Assume that you have a table that has a DML trigger in Microsoft SQL Server 2008 R2, SQL Server 2012, or SQL Server 2014 and in that trigger you join inserted/deleted table with other tables. When you execute a DML statement on this table, an access violation may occur during trigger compilation and you receive the following error:
A severe error occurred on the current command. The results, if any, should be discarded.
Additionally, following errors are logged in SQL Server error log:
<Date><Time> spid# ***Stack Dump being sent to <FilePath>\SQLDumpxxx.txt
<Date><Time> spid# SqlDumpExceptionHandler: Process # generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
<Date><Time> spid# * *******************************************************************************
<Date><Time> spid# *
<Date><Time> spid# * BEGIN STACK DUMP:
<Date><Time> spid# * <Date><Time> spid #
<Date><Time> spid# *
<Date><Time> spid# *
<Date><Time> spid# * Exception Address = 00000000009E4F2A Module(sqlservr+00000000002D4F2A)
<Date><Time> spid# * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
<Date><Time> spid# * Access Violation occurred writing address 0000000000000000
<Date><Time> spid# * Input Buffer 510 bytes -
<Date><Time> spid# * SQL_query_code

Workaround


To work around the issue, do not use the inserted/deleted table directly in a query joining it with other tables, instead cache it in a temp table and use the temp table in the query.

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.