dbTalk Databases Forums  

Starting a DTS package from Store Procedure

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


Discuss Starting a DTS package from Store Procedure in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Julie
 
Posts: n/a

Default Starting a DTS package from Store Procedure - 11-11-2003 , 07:53 AM






Dear All,

I am trying to start a DTS package from a Store procedure.
It doesn't like the 'LoadFromSQLServer' command. Can
anyone tell me what is wrong ?

Here is the code

DECLARE @hPkg int
DECLARE @hResult int

DECLARE @sPackageName varchar(255)
DECLARE @sServerName varchar(255)
DECLARE @sServerUserName varchar(255)
DECLARE @sServerPassword varchar(255)
DECLARE @sMethod varchar(255)
DECLARE @lFlags int
DECLARE @src varchar(40)
DECLARE @desc varchar(100)

SET @sPackageName = 'A'
SET @sServerName = 'INVESTMENTS1'
SET @sMethod = ''
SET @sServerUserName = ''
SET @sServerPassword = ''
SET @lFlags = 256

EXEC @hResult = sp_OACreate 'DTS.Package', @hPkg OUT
if @hResult <> 0
Print 'Cannot Create'
else
Print 'Created'

SET @sMethod = 'LoadFromSQLServer'
EXEC @hResult = sp_OAMethod @hPkg, @sMethod, NULL,
@sServerName, @sServerUserName, @sServerPassword,
@lFlags, 'A'

IF @hResult <> 0
BEGIN
EXEC sp_OAGetErrorInfo NULL, @src OUT, @desc OUT
SELECT Info = 'Method - '+@sMethod, Source = @src,
Description = @desc
END
ELSE
Print 'It Worked'

EXEC @hResult = sp_OADestroy @hPkg

Thanks
J

Reply With Quote
  #2  
Old   
V Batishchev
 
Posts: n/a

Default Re: Starting a DTS package from Store Procedure - 11-12-2003 , 04:04 AM






I would better add schedule to the package from SP.
Have a look at msdb..sp_add_jobschedule / msdb..sp_delete_jobschedule /
msdb..sp_help_jobschedule
HTH

Slav.


"Julie" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Dear All,

I am trying to start a DTS package from a Store procedure.
It doesn't like the 'LoadFromSQLServer' command. Can
anyone tell me what is wrong ?

Here is the code

DECLARE @hPkg int
DECLARE @hResult int

DECLARE @sPackageName varchar(255)
DECLARE @sServerName varchar(255)
DECLARE @sServerUserName varchar(255)
DECLARE @sServerPassword varchar(255)
DECLARE @sMethod varchar(255)
DECLARE @lFlags int
DECLARE @src varchar(40)
DECLARE @desc varchar(100)

SET @sPackageName = 'A'
SET @sServerName = 'INVESTMENTS1'
SET @sMethod = ''
SET @sServerUserName = ''
SET @sServerPassword = ''
SET @lFlags = 256

EXEC @hResult = sp_OACreate 'DTS.Package', @hPkg OUT
if @hResult <> 0
Print 'Cannot Create'
else
Print 'Created'

SET @sMethod = 'LoadFromSQLServer'
EXEC @hResult = sp_OAMethod @hPkg, @sMethod, NULL,
@sServerName, @sServerUserName, @sServerPassword,
@lFlags, 'A'

IF @hResult <> 0
BEGIN
EXEC sp_OAGetErrorInfo NULL, @src OUT, @desc OUT
SELECT Info = 'Method - '+@sMethod, Source = @src,
Description = @desc
END
ELSE
Print 'It Worked'

EXEC @hResult = sp_OADestroy @hPkg

Thanks
J



Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Starting a DTS package from Store Procedure - 11-12-2003 , 08:57 AM



Have you seen this?

Execute a package from T-SQL
(http://www.sqldts.com/default.aspx?210)

--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Julie" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Dear All,

I am trying to start a DTS package from a Store procedure.
It doesn't like the 'LoadFromSQLServer' command. Can
anyone tell me what is wrong ?

Here is the code

DECLARE @hPkg int
DECLARE @hResult int

DECLARE @sPackageName varchar(255)
DECLARE @sServerName varchar(255)
DECLARE @sServerUserName varchar(255)
DECLARE @sServerPassword varchar(255)
DECLARE @sMethod varchar(255)
DECLARE @lFlags int
DECLARE @src varchar(40)
DECLARE @desc varchar(100)

SET @sPackageName = 'A'
SET @sServerName = 'INVESTMENTS1'
SET @sMethod = ''
SET @sServerUserName = ''
SET @sServerPassword = ''
SET @lFlags = 256

EXEC @hResult = sp_OACreate 'DTS.Package', @hPkg OUT
if @hResult <> 0
Print 'Cannot Create'
else
Print 'Created'

SET @sMethod = 'LoadFromSQLServer'
EXEC @hResult = sp_OAMethod @hPkg, @sMethod, NULL,
@sServerName, @sServerUserName, @sServerPassword,
@lFlags, 'A'

IF @hResult <> 0
BEGIN
EXEC sp_OAGetErrorInfo NULL, @src OUT, @desc OUT
SELECT Info = 'Method - '+@sMethod, Source = @src,
Description = @desc
END
ELSE
Print 'It Worked'

EXEC @hResult = sp_OADestroy @hPkg

Thanks
J



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 - 2012, Jelsoft Enterprises Ltd.