Hi Peter,
What Tibor correctly suggests is documented in BOL under the "Duration of
SET Options" section of
http://msdn.microsoft.com/library/en-us/acdata/ac_8_qd_03_35df.asp.
Keep in mind that the indexed view itself must *already* have been created
using those settings (from
http://msdn.microsoft.com/library/en-us/tsqlref/ts_create_64l4.asp):
{
When **creating** indexed views or manipulating rows in tables
participating in an indexed view, seven SET options must be assigned
specific values. The SET options ARITHABORT, CONCAT_NULL_YIELDS_NULL,
QUOTED_IDENTIFIER, ANSI_NULLS, ANSI_PADDING, and ANSI_WARNING must be ON.
The SET option NUMERIC_ROUNDABORT must be OFF.
Quote:}
(** is my emphasis).
Finally, from the same URL:
{
In addition, for a SELECT statement that involves an indexed view, if the
values of any of the SET options are not the required values, SQL Server
processes the SELECT without considering the indexed view substitution.
Quote:}
is what I suspect you wish that code to accommodate. You can verify whether
that is accomodated (whether an indexed view is being used) via the use of
SHOWPLAN.
Thanks,
Bill Hollinshead
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no
rights. Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.