Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-21
4
Medium Priority
?
316 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 43

Accepted Solution

by:
Eugene Z earned 1500 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 43

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 7

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

688 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