dbTalk Databases Forums  

HELP... start a job from code or a stored procedure

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss HELP... start a job from code or a stored procedure in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
meyvn77@yahoo.com
 
Posts: n/a

Default HELP... start a job from code or a stored procedure - 09-12-2005 , 09:49 AM






I would like to know if it is possible to start a job from a stored
procedure?

I have a DTS that I set as a job and would like to either call it from
an ADP with

Conn.Execute "EXEC msdb..sp_start_job @job_name = 'Volusia'"

OR just strat it with a stored procedure and call the stored procedure
from the adp


CREATE PROCEDURE sde.Volusia_Import AS
EXEC msdb..sp_start_job @job_name = 'Volusia_Import'
GO


I tried both of these and it does not give me an error but it does not
run the job... what am I missing?

Thanks,
Chuck


Reply With Quote
  #2  
Old   
Tony Sebion
 
Posts: n/a

Default Re: HELP... start a job from code or a stored procedure - 09-12-2005 , 02:39 PM






You can run DTS packages with the OLE Automation objects or with
xp_cmdshell to run dtsrun.exe. You can find out about dtsrun in Books
Online, and an example using the OLE Automation objects appears below.

I'm copying this example from
http://www.mssqlcity.com/faq/devel/dtsviaqa.htm :

DECLARE @object int
DECLARE @hr int

--create a package object
EXEC @hr = sp_OACreate 'DTS.Package', @object OUTPUT
if @hr <> 0
BEGIN
print 'error create DTS.Package'
RETURN
END

EXEC @hr = sp_OAMethod @object, 'LoadFromStorageFile',
NULL, 'C:\NewPack.dts', ''
IF @hr <> 0
BEGIN
print 'error LoadFromStorageFile'
RETURN
END

EXEC @hr = sp_OAMethod @object, 'Execute'
IF @hr <> 0
BEGIN
print 'Execute failed'
RETURN
END

Good luck,
Tony Sebion

"meyvn77 (AT) yahoo (DOT) com" <meyvn77 (AT) yahoo (DOT) com> wrote


Quote:
I would like to know if it is possible to start a job from a stored
procedure?

I have a DTS that I set as a job and would like to either call it from
an ADP with

Conn.Execute "EXEC msdb..sp_start_job @job_name = 'Volusia'"

OR just strat it with a stored procedure and call the stored procedure
from the adp


CREATE PROCEDURE sde.Volusia_Import AS
EXEC msdb..sp_start_job @job_name = 'Volusia_Import'
GO


I tried both of these and it does not give me an error but it does not
run the job... what am I missing?

Thanks,
Chuck


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.