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_codeResolution
The issue was first fixed in the following cumulative update of SQL Server.
Cumulative Update 1 for SQL Server 2012 SP2 /en-us/help/2976982
Cumulative Update 2 for SQL Server 2014 /en-us/help/2967546
Cumulative Update 10 for SQL Server 2012 SP1 /en-us/help/2954099
Cumulative Update 12 for SQL Server 2008 R2 SP2 /en-us/help/2938478
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:
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.