Incorrect Set Options issue

Incorrect Set Options issue

Post by tom » Tue, 15 Oct 2002 10:19:14



I am trying to insert data into a table and continue to
receive the following error message:
"INSERT failed because the following SET options have
incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'."  

I have tried every combination of set options for
ANSI_Nulls and Quoted_Identifier right before the insert
statement but it still does not work.  

If I use Query Analyzer to insert the information it
functions properly but when called via the following
stored procedure the problem occurs.

CREATE PROCEDURE Courses_Link
(


)
AS

set nocount on
















declare curCategories1 cursor for
Select GC.Title, GC.GradePercentage, GC.BGColor,
DropLowestGrade, DisplayRank, MarkingPeriodID, SynchGuid
from GradeCategory AS GC

open curCategories1



begin
        if(Not Exists (select * from GradeCategory



        begin
                set quoted_identifier on
                set ArithAbort on
                --set ansi_nulls on








        -- PROBLEM OCCURS HERE
                insert GradeCategory
                ([Title], [GradePercentage],
[DisplayRank], [BGColor], [DropLowestGrade], [CourseID],
[MarkingPeriodID], [SynchGuid])
                values

        end

        fetch next from curCategories1 into

end

close curCategories1
deallocate curCategories1

declare curCategories2 cursor for
Select GC.Title, GC.GradePercentage, GC.BGColor,
DropLowestGrade, DisplayRank, MarkingPeriodID, SynchGuid
from GradeCategory AS GC

open curCategories2


begin


GradeCategory




/*

        begin
                insert GradeCategory
                (Title, GradePercentage, DisplayRank,
BGColor, DropLowestGrade, CourseID, MarkingPeriodID,
SynchGuid)
                values

        end
        else
        Begin
                update GradeCategory
                set





                where

        End
*/

        fetch next from curCategories2 into

end

close curCategories2
deallocate curCategories2



return
GO

I have marked where the problem occurs with -- PROBLEM
OCCURS HERE.

Other information that may be relevant:
- I have Indexed Views that are referencing the
GradeCategory table
- Running SQL Server 2000 Enterprise Edition

Any advice would be greatly appreciated.

Thanks in advance.

Tom

 
 
 

Incorrect Set Options issue

Post by Dan Guzma » Tue, 15 Oct 2002 13:02:25


Perhaps the stored procedure was created or altered with ANSI_NULLS or
QUOTED_IDENTIFIER OFF.  These settings are saved and are used at
execution time, overriding the connection settings.

You might try recreating the procedure with these options on.

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy  Neil Pike):

http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------


> I am trying to insert data into a table and continue to
> receive the following error message:
> "INSERT failed because the following SET options have
> incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'."

> I have tried every combination of set options for
> ANSI_Nulls and Quoted_Identifier right before the insert
> statement but it still does not work.

> If I use Query Analyzer to insert the information it
> functions properly but when called via the following
> stored procedure the problem occurs.

> CREATE PROCEDURE Courses_Link
> (


> )
> AS

> set nocount on
















> declare curCategories1 cursor for
> Select GC.Title, GC.GradePercentage, GC.BGColor,
> DropLowestGrade, DisplayRank, MarkingPeriodID, SynchGuid
> from GradeCategory AS GC

> open curCategories1

> fetch next from curCategories1 into



> begin
> if(Not Exists (select * from GradeCategory

> MarkingPeriodID =


> begin
> set quoted_identifier on
> set ArithAbort on
> --set ansi_nulls on








> -- PROBLEM OCCURS HERE
> insert GradeCategory
> ([Title], [GradePercentage],
> [DisplayRank], [BGColor], [DropLowestGrade], [CourseID],
> [MarkingPeriodID], [SynchGuid])
> values



> end

> fetch next from curCategories1 into



> end

> close curCategories1
> deallocate curCategories1

> declare curCategories2 cursor for
> Select GC.Title, GC.GradePercentage, GC.BGColor,
> DropLowestGrade, DisplayRank, MarkingPeriodID, SynchGuid
> from GradeCategory AS GC

> open curCategories2
> fetch next from curCategories2 into



> begin


> GradeCategory

> MarkingPeriodID =



> /*

> begin
> insert GradeCategory
> (Title, GradePercentage, DisplayRank,
> BGColor, DropLowestGrade, CourseID, MarkingPeriodID,
> SynchGuid)
> values



> end
> else
> Begin
> update GradeCategory
> set
> GradePercentage =



> DropLowestGrade =


> where

> End
> */

> fetch next from curCategories2 into



> end

> close curCategories2
> deallocate curCategories2



> return
> GO

> I have marked where the problem occurs with -- PROBLEM
> OCCURS HERE.

> Other information that may be relevant:
> - I have Indexed Views that are referencing the
> GradeCategory table
> - Running SQL Server 2000 Enterprise Edition

> Any advice would be greatly appreciated.

> Thanks in advance.

> Tom