Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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.

743 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

13 Experts available now in Live!

Get 1:1 Help Now