dbTalk Databases Forums  

Stored Procedure to Execute Local DTS Package

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


Discuss Stored Procedure to Execute Local DTS Package in the microsoft.public.sqlserver.dts forum.



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

Default Stored Procedure to Execute Local DTS Package - 07-13-2004 , 01:23 PM






I found a great piece of code on the web that allows me to execute a DTS
package on the server by using a stored procedure. Here is the code.

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:\test.dts', '' /* I would like to change reference to the SQL
Server stored DTS package located under Local packages */
IF @hr <> 0
BEGIN
print 'error LoadFromStorageFile'
RETURN
END

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

The code works great but the problem is that I have to use the SQL script
DTS file stored on the hard drive. I would like to use the DTS package on
the SQL Server under Local Packages. How do I reference the Local Packages
under SQL Server rather than using the DTS file stored on the hard drive?

Thank you in advance,
Ken



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

Default Re: Stored Procedure to Execute Local DTS Package - 07-13-2004 , 02:21 PM






In article <eD8KLaQaEHA.2840 (AT) TK2MSFTNGP11 (DOT) phx.gbl>, Ken wrote:
Quote:
I found a great piece of code on the web that allows me to execute a DTS
package on the server by using a stored procedure. Here is the code.

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:\test.dts', '' /* I would like to change reference to the SQL
Server stored DTS package located under Local packages */
IF @hr <> 0
BEGIN
print 'error LoadFromStorageFile'
RETURN
END

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

The code works great but the problem is that I have to use the SQL script
DTS file stored on the hard drive. I would like to use the DTS package on
the SQL Server under Local Packages. How do I reference the Local Packages
under SQL Server rather than using the DTS file stored on the hard drive?

Thank you in advance,
Ken

There are a few examples out there on the web for you to look at

Here is ours

http://www.databasejournal.com/featu...le.php/1459181


Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
www.konesans.com - for all your consultancy needs





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.