Tuesday, May 20, 2008

SQL 2005 and SET OPTIONS Tip

In SQL 2005 if you have stored procedure or SQL statement that execute update operation on table with computed column that refer to function, or have update triggers, one of the following errors may occur:

  • Msg 8624, Level 16, State 1, Procedure Patient_Update, Line 96
    Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.
  • UPDATE failed because the following SET options have incorrect settings: 'ANSI_NULLS'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods.

The cause of this problem can be that the SET OPTIONS for stored procedure is different in the computed column function or update triggers.

For example, if computed column function has SET ANSI_NULLS ON and stored procedure has SET ANSI_NULLS OFF, one of the above errors may occur

To resolve this, ensure that you are using the same SET OPTION in the stored procedures, computed columns functions and update triggers.