Sqlserver-dba.com

SQL Server recompile error after upgrade from 2000 to 2005

Upon upgrading a SQL Server 2000 to SQL Server 2005 Standard Edition instance –  this error message appeared on a SQL Server trace error event:

Msg 2801, Level 16, State 1, Procedure myTrigger, Line 13

The definition of object ‘myTrigger’  has changed since it was compiled.

The statement has been terminated.

Using a trace I isolated the trigger which caused this error. The developers had created the trigger in the following format:

 

Alter table appEvent DISABLE Trigger ALL

 <some dml statements >

 Alter table appEvent ENABLE Trigger ALL

When commenting out the DISABLE TRIGGER ALL  and ENABLE TRIGGER ALL  the code works without error – but does have a  data knock-on effect. The developers  explained they wrote this code to avoid creating duplicates in the target data set – fronm other triggers executing.

 The error is occuring because : the ALL option is used which affects all triggers on the table , and as an INSERT statement is used which fires the trigger which actually is doing the ENABLE\DISABLE. This creates the error message as trigger recompilation needs to occur .

 I advised them to use either application logic to prepare data adequately or add other constraints at the table level. 

 

Source:Jack Vamvas (http://www.sqlserver-dba.com)

 


Author: Jack Vamvas (http://www.sqlserver-dba.com)

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact