Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 SQL Server Agent and Quoted Identifier

Author  Topic 

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2011-04-20 : 14:23:58

One of my SQL scripts is failing, when executed as a part of SQL Agent Job, but succeeds in SSMS.

I realized that this is because the default Quoted Identifier setting is OFF for the Agent but, ON for SSMS.

Is there a way to set the default setting to ON, for the Agent?

------------------------
I think, therefore I am - Rene Descartes

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-20 : 14:38:05
Have you tried changing the default connections for the server? Right-click the server node in SSMS, choose Properties, and check quoted identifier under the Connections pane.

You should probably restart SQL Agent after you make that change.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-20 : 15:22:38
Why not just add it into the job step?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2011-04-20 : 15:44:14
quote:
Originally posted by tkizer

Why not just add it into the job step?


...to many jobs to modify.

------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-20 : 16:05:39
Run this code and copy the results to a new window:
SELECT 'EXEC sp_update_jobstep @job_id=''' + 
CAST(job_id AS NVARCHAR(36)) + ''',
@step_id=1,
@command=N''' + N'SET QUOTED_IDENTIFIER ON;
' + REPLACE(command,N'''',N'''''') + N'''', *
FROM msdb.dbo.sysjobsteps
WHERE step_id=1 AND subsystem='TSQL'
I'd suggest testing that first on a few jobs before running the whole thing.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-20 : 16:13:03
quote:
Originally posted by ravilobo

quote:
Originally posted by tkizer

Why not just add it into the job step?


...to many jobs to modify.




Why do you have to update them all? You said one script is failing.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2011-04-20 : 16:17:53
Thanks a lot Rob!

------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-20 : 16:20:55
I should add that you need to run my code in text mode, not grid mode, otherwise you'll lose line breaks that could screw up the update.
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2011-04-20 : 16:25:51
quote:
Originally posted by robvolk
I should add that you need to run my code in text mode....



...will do that! Thanks a lot. Big Help!

------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page
   

- Advertisement -