My question is somewhat related to UPDATE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER' .
I am using SQL Query Notifications to enable caching for my application from the database and have run into a strange behaviour that I can't fully explain.
If I run some SQL query notification code
using (SqlCommand command=new SqlCommand("SELECT MyColumn1, MyColumn2, etc... FROM dbo.StockSupplierCode", connection))
{
SqlDependency dependency=new SqlDependency(command);
dependency.OnChange += new OnChangeEventHandler(OnDependencyChange);
command.ExecuteReader();
}
After running this the first time on my database if I try to update the affected table I get the error:
Msg 1934, Level 16, State 1, Procedure Stock_NonIntTrigger, Line 14 [Batch Start Line 0] UPDATE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.
The error specifically refers to it occuring in a named trigger in my database called Stock_NonIntTrigger
.
This error will now persist anytime I subsequently try to update this table.
HOWEVER if I open this trigger, change nothing and resave it, the error disappears.
My only assumption is that when I resave this trigger that SQL Query Analyser is perhaps adding the QUOTE_IDENTIFIER ON syntax HOWEVER when I reopen the same trigger using sp_helptext
it appears unaffected and identical to the original.
Yet the updates will now succeed.
Anyone able to provide any insight into:
- Why might Query Notifications be causing this error?
- Why does resaving the trigger make the error go away?