Solved

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

Posted on 2013-01-21
4
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
Eugene Z 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:Eugene Z
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 40

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

735 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