incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'.

incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'.

Post by Matt Ri » Tue, 28 Oct 2003 08:01:52



Getting an "incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'."
error after creating a view.

We wanted a composite unique constraint that ignored nulls, so we set
up a view using the following script:

/* --- start --- */
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT

GO

CREATE VIEW vw_MyView
WITH SCHEMABINDING
AS
SELECT Col1, Col2 FROM dbo.MyTable WHERECol2 IS NOT NULL

GO
/* --- end --- */

and then added the constraint to the new view

/* --- start --- */
CREATE UNIQUE CLUSTERED INDEX AK_MyTable_Constraint1 ON
vw_MyView(Col1, Col2)

GO
/* --- end --- */

I thought we were doing fine, 'til we started running some DELETE
stored procedures and got the above error.  The error also cited
ARITHABORT as an incorrect setting until we ran this script:

/* --- start --- */
USE master


WHERE config = 1534


RECONFIGURE
/* --- end --- */

TIA to anyone kind enough to shed some light on this for me.  Is there
something we should have done differently in creating the view and
index?  If not, what's the procedure for working through these
settings errors?

I've read through some other threads on this subject, but didn't
really find what I was looking for.  Thanks again for any help.  Would
be appreciated.

-matt

 
 
 

incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'.

Post by Doug Hanhar » Tue, 28 Oct 2003 08:35:23


When you're using indexed views, the stored procedures
that call the view need to also have been created using
the exact same settings.  Not sure if that's the problem
in this case, but it's been a problem for me before.

HTH,

Doug

Quote:>-----Original Message-----
>Getting an "incorrect settings: 'ANSI_NULLS.,

QUOTED_IDENTIFIER'."
>error after creating a view.

>We wanted a composite unique constraint that ignored
nulls, so we set
>up a view using the following script:

>/* --- start --- */
>BEGIN TRANSACTION
>SET QUOTED_IDENTIFIER ON
>SET ARITHABORT ON
>SET NUMERIC_ROUNDABORT OFF
>SET CONCAT_NULL_YIELDS_NULL ON
>SET ANSI_NULLS ON
>SET ANSI_PADDING ON
>SET ANSI_WARNINGS ON
>COMMIT

>GO

>CREATE VIEW vw_MyView
>WITH SCHEMABINDING
>AS
>SELECT Col1, Col2 FROM dbo.MyTable WHERECol2 IS NOT NULL

>GO
>/* --- end --- */

>and then added the constraint to the new view

>/* --- start --- */
>CREATE UNIQUE CLUSTERED INDEX AK_MyTable_Constraint1 ON
>vw_MyView(Col1, Col2)

>GO
>/* --- end --- */

>I thought we were doing fine, 'til we started running
some DELETE
>stored procedures and got the above error.  The error
also cited
>ARITHABORT as an incorrect setting until we ran this
script:

>/* --- start --- */
>USE master


>WHERE config = 1534


>RECONFIGURE
>/* --- end --- */

>TIA to anyone kind enough to shed some light on this for
me.  Is there
>something we should have done differently in creating
the view and
>index?  If not, what's the procedure for working through
these
>settings errors?

>I've read through some other threads on this subject,
but didn't
>really find what I was looking for.  Thanks again for
any help.  Would
>be appreciated.

>-matt
>.


 
 
 

incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'.

Post by Simon Hay » Tue, 28 Oct 2003 12:41:09



> Getting an "incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'."
> error after creating a view.

> We wanted a composite unique constraint that ignored nulls, so we set
> up a view using the following script:

> /* --- start --- */
> BEGIN TRANSACTION
> SET QUOTED_IDENTIFIER ON
> SET ARITHABORT ON
> SET NUMERIC_ROUNDABORT OFF
> SET CONCAT_NULL_YIELDS_NULL ON
> SET ANSI_NULLS ON
> SET ANSI_PADDING ON
> SET ANSI_WARNINGS ON
> COMMIT

> GO

> CREATE VIEW vw_MyView
> WITH SCHEMABINDING
> AS
> SELECT Col1, Col2 FROM dbo.MyTable WHERECol2 IS NOT NULL

> GO
> /* --- end --- */

> and then added the constraint to the new view

> /* --- start --- */
> CREATE UNIQUE CLUSTERED INDEX AK_MyTable_Constraint1 ON
> vw_MyView(Col1, Col2)

> GO
> /* --- end --- */

> I thought we were doing fine, 'til we started running some DELETE
> stored procedures and got the above error.  The error also cited
> ARITHABORT as an incorrect setting until we ran this script:

> /* --- start --- */
> USE master


> WHERE config = 1534


> RECONFIGURE
> /* --- end --- */

> TIA to anyone kind enough to shed some light on this for me.  Is there
> something we should have done differently in creating the view and
> index?  If not, what's the procedure for working through these
> settings errors?

> I've read through some other threads on this subject, but didn't
> really find what I was looking for.  Thanks again for any help.  Would
> be appreciated.

> -matt

You need to have those SET options in force not only when you create
the view and indexes, but also when you query it. So your client
application has to use the same settings in its code - OLE DB/ODBC
does this automatically, with the exception of ARITHABORT. In BOL,
Microsoft recommend to set this on at the server level, as you've done
already.

If you still have errors when using the indexed view, it is most
likely that you have some stored procedures which have been created
with ANSI_NULLS and QUOTED_IDENTIFIER off, not on - those settings are
fixed when the procedure is created. You can recreate the procedures
with the correct SET options, and it should work fine, although of
course that change could affect other code, so you need to test it.

Simon

 
 
 

incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'.

Post by Kalen Delane » Tue, 28 Oct 2003 17:12:24


Hi Matt

As Doug and Simon have said, stored procedures created with certain SET
options enabled will always run with those options, even if you SET them
differently in the batch that calls the procedure. The only two that are
stored this way are "ANSI_NULLS" and "QUOTED_IDENTIFIER". I call these
'sticky' options, because their values 'stick' to the stored procedure.
Since these are the two you are getting messages about, it seems likely that
your procedure was created with the wrong values for these options,.

You can verify whether these options are set with the procedure by using the
OBJECTPROPERTY FUNCTION:

SELECT OBJECTPROPERTY(object_id('proc name'), 'ExecIsAnsiNullsOn' )

SELECT OBJECTPROPERTY(object_id('proc name'), 'ExecIsQuotedIdentOn')

If the functions return 1, the property was set, if they return 0, it was
NOT set for the procedure, and you MUST recreate the procedure to use it
with an indexed view.

(If the function returns NULL, it means you typed something wrong. :-) )
--
HTH
----------------
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com


> Getting an "incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'."
> error after creating a view.

> We wanted a composite unique constraint that ignored nulls, so we set
> up a view using the following script:

> /* --- start --- */
> BEGIN TRANSACTION
> SET QUOTED_IDENTIFIER ON
> SET ARITHABORT ON
> SET NUMERIC_ROUNDABORT OFF
> SET CONCAT_NULL_YIELDS_NULL ON
> SET ANSI_NULLS ON
> SET ANSI_PADDING ON
> SET ANSI_WARNINGS ON
> COMMIT

> GO

> CREATE VIEW vw_MyView
> WITH SCHEMABINDING
> AS
> SELECT Col1, Col2 FROM dbo.MyTable WHERECol2 IS NOT NULL

> GO
> /* --- end --- */

> and then added the constraint to the new view

> /* --- start --- */
> CREATE UNIQUE CLUSTERED INDEX AK_MyTable_Constraint1 ON
> vw_MyView(Col1, Col2)

> GO
> /* --- end --- */

> I thought we were doing fine, 'til we started running some DELETE
> stored procedures and got the above error.  The error also cited
> ARITHABORT as an incorrect setting until we ran this script:

> /* --- start --- */
> USE master


> WHERE config = 1534


> RECONFIGURE
> /* --- end --- */

> TIA to anyone kind enough to shed some light on this for me.  Is there
> something we should have done differently in creating the view and
> index?  If not, what's the procedure for working through these
> settings errors?

> I've read through some other threads on this subject, but didn't
> really find what I was looking for.  Thanks again for any help.  Would
> be appreciated.

> -matt

 
 
 

incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'.

Post by Matt Ri » Tue, 28 Oct 2003 22:18:58


Thank you all for your responses.  I was able to get past the error by
adding

SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO

to the top of my trouble Stored Procedures in EM.  What a maintainance
nightmare!  We make all our changes to DB table structure using change
scripts, so that we can execute the batch of scripts on any of our
development/test/production databases.  These manual changes needed to
make a new view work definitely monkeys things up. I suppose I'm going
to have to give this some more thought.

I'm surprised this is not a larger issue.  Leads me to wonder what I'm
doing wrong...

thanks again,
-matt


> Hi Matt

> As Doug and Simon have said, stored procedures created with certain SET
> options enabled will always run with those options, even if you SET them
> differently in the batch that calls the procedure. The only two that are
> stored this way are "ANSI_NULLS" and "QUOTED_IDENTIFIER". I call these
> 'sticky' options, because their values 'stick' to the stored procedure.
> Since these are the two you are getting messages about, it seems likely that
> your procedure was created with the wrong values for these options,.

> You can verify whether these options are set with the procedure by using the
> OBJECTPROPERTY FUNCTION:

> SELECT OBJECTPROPERTY(object_id('proc name'), 'ExecIsAnsiNullsOn' )

> SELECT OBJECTPROPERTY(object_id('proc name'), 'ExecIsQuotedIdentOn')

> If the functions return 1, the property was set, if they return 0, it was
> NOT set for the procedure, and you MUST recreate the procedure to use it
> with an indexed view.

> (If the function returns NULL, it means you typed something wrong. :-) )
> --
> HTH
> ----------------
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com



> > Getting an "incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'."
> > error after creating a view.

> > We wanted a composite unique constraint that ignored nulls, so we set
> > up a view using the following script:

> > /* --- start --- */
> > BEGIN TRANSACTION
> > SET QUOTED_IDENTIFIER ON
> > SET ARITHABORT ON
> > SET NUMERIC_ROUNDABORT OFF
> > SET CONCAT_NULL_YIELDS_NULL ON
> > SET ANSI_NULLS ON
> > SET ANSI_PADDING ON
> > SET ANSI_WARNINGS ON
> > COMMIT

> > GO

> > CREATE VIEW vw_MyView
> > WITH SCHEMABINDING
> > AS
> > SELECT Col1, Col2 FROM dbo.MyTable WHERECol2 IS NOT NULL

> > GO
> > /* --- end --- */

> > and then added the constraint to the new view

> > /* --- start --- */
> > CREATE UNIQUE CLUSTERED INDEX AK_MyTable_Constraint1 ON
> > vw_MyView(Col1, Col2)

> > GO
> > /* --- end --- */

> > I thought we were doing fine, 'til we started running some DELETE
> > stored procedures and got the above error.  The error also cited
> > ARITHABORT as an incorrect setting until we ran this script:

> > /* --- start --- */
> > USE master


> > WHERE config = 1534


> > RECONFIGURE
> > /* --- end --- */

> > TIA to anyone kind enough to shed some light on this for me.  Is there
> > something we should have done differently in creating the view and
> > index?  If not, what's the procedure for working through these
> > settings errors?

> > I've read through some other threads on this subject, but didn't
> > really find what I was looking for.  Thanks again for any help.  Would
> > be appreciated.

> > -matt

 
 
 

1. Msg 1934, incorrect QUOTED_IDENTIFIER setting - why???

I'm using SQL 2000, no service pack yet.

I get the following message sometimes when executing a string of stored
procs.

Server: Msg 1934, Level 16, State 1, Procedure drl_ChemInv, Line 456
INSERT failed because the following SET options have incorrect settings:
'QUOTED_IDENTIFIER'.

I don't think I need to change anything from the default, so why does Query
Analyzer turn these on and off when it displays my stored proc?

What should these be set to?  and, why is Query Analyzer always changing it?

Thanks - -

Jim Tebbel

2. CA-San Diego-67936--ORACLE-RDBMS-SQL-PL/SQL-SQR-GUI-System Design-Database Desig

3. INSERT failed because the following SET options have incorrect settings: 'ANSI_NULLS., ARITHABORT'.

4. headstart212 patch for des6?

5. SET OPTION 'QUOTED_IDENTIFIER' error

6. Updating PrimaryKey in VC++ 6.0

7. ANSI_NULLS and QUOTED_IDENTIFIER

8. OLE DB adding and changing a rowset problem

9. 'Incorrect Syntax Near' message is worthless

10. Incorrect syntax near 'COLLATE'

11. ODBC SQL Server Driver:Incorrect syntax near'.'.(#170)

12. Incorrect syntax near ',' using MSQuery

13. Incorrect syntax near '.'.(#170)