Solved

SQL Runs as a Query but not as a step in a job

Posted on 2013-01-21
4
310 Views
Last Modified: 2013-01-21
Hi,

We have some jobs that run and insert data from one table to another using a view.  Something like:

Insert into table1
(column1, column2, column3)
select column1, column2, column3 from DB2.dbo.View1

If I run that code as a query it executes fine.  However when I run it as a step in a job I get this error:

"INSERT 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. [SQLSTATE 42000] (Error 1934).  The step failed.

When I got the error I searched for it and found many posts that said I should turn "Quoted_Identifier" on when creating the view.  I had done that but just to be sure I dropped all the views and re-created them.  I still get the same error.

Any ideas?
0
Comment
Question by:afacts
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
EugeneZ earned 500 total points
ID: 38803200
== try to run
SET QUOTED_IDENTIFIER ON
GO

Insert into table1
(column1, column2, column3)
select column1, column2, column3 from DB2.dbo.View1


----------------------------
--if did not help
--try to recreate you view


SET QUOTED_IDENTIFIER ON
GO
create view dbo.View1
-------


see more:
INSERT/UPDATE failed because the following SET options have incorrect settings: ‘QUOTED_IDENTIFIER’ …
http://beginsql.wordpress.com/2012/02/04/insertupdate-failed-because-the-following-set-options-have-incorrect-settings-quoted_identifier/
0
 
LVL 42

Expert Comment

by:EugeneZ
ID: 38803211
SET QUOTED_IDENTIFIER (Transact-SQL)
http://msdn.microsoft.com/en-us/library/ms174393(v=sql.100).aspx

When SET QUOTED_IDENTIFIER is ON, identifiers can be delimited by double quotation marks, and literals must be delimited by single quotation marks. When SET QUOTED_IDENTIFIER is OFF, identifiers cannot be quoted and must follow all Transact-SQL rules for identifiers. For more information, see Identifiers. Literals can be delimited by either single or double quotation marks.
0
 
LVL 39

Expert Comment

by:lcohan
ID: 38803215
"SQL Runs as a Query but not as a step in a job"
Is the login that "Runs as a Query " identical with the account starting SQL Agent? a job step runs under SQL Agent Service account and a query as the user connected to the database.
0
 
LVL 6

Expert Comment

by:RaithZ
ID: 38803219
If QUOTED_IDENTIFIER has been on the whole time, its possible it needs to be turned off.  I just say this because it seems logical.  If the above suggestions fail, give this a try.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now