Solved

Uses OLE in a sp run by SQL Server Agent.

Posted on 2014-10-01
5
143 Views
Last Modified: 2014-10-13
Hello,

I want to run a stored procedure using SQL Server Agent.

This stored procedure uses OLE and calls sp_AOCreate.

When testing I used the following:

sp_configure ‘show advanced options’, 1;
 GO
 RECONFIGURE;
 GO
 sp_configure ‘Ole Automation Procedures’, 1;
 GO
 RECONFIGURE;
 GO

Open in new window


to enable  OLE.

How should i run this job under SQL Server Agent?

Does running the above script only work for the current session, or does it apply to all uses in the database?
0
Comment
Question by:soozh
[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
  • 3
  • 2
5 Comments
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 40354119
It applies to instance so if you already ran those commands to enable the OLE automation now create the job to run the  sp_AOCreate as you would for any stored procedure:
DECLARE @object int;
EXEC sp_OACreate 'YourOLEObjHere', @object OUT;

Open in new window

0
 

Author Comment

by:soozh
ID: 40354123
Hello,

I may not have been clear.  I already have a working SP, that i have tested a few times.  So i know that the code is ok.

What i need to know is how enable the OLE option for SQL Server Agent and this job in particular.

/r
0
 
LVL 50

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40354134
You only need to enable it once and will be permanent for the instance but if you only have it enable for running the job and then disable it then you need to put that code in the job and also for disable it after. Like this:
sp_configure ‘show advanced options’, 1;
 GO
 RECONFIGURE;
 GO
 sp_configure ‘Ole Automation Procedures’, 1;
 GO
 RECONFIGURE WITH OVERRIDE;
 GO

---Your code goes here
(...)


sp_configure ‘Ole Automation Procedures’, 0;
GO
RECONFIGURE WITH OVERRIDE;
GO
sp_configure ‘show advanced options’, 0;
GO

Open in new window

0
 

Author Comment

by:soozh
ID: 40354200
ok... thanks for that.. but will the job have to be run as an administrator?
0
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 40354205
Yes, you need to provide a user with sysadmin role so it can enable the OLE automation procedure.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

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.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

751 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