Solved

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

Posted on 2013-01-21
4
308 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.

910 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

21 Experts available now in Live!

Get 1:1 Help Now