dbTalk Databases Forums  

Run a DTS from a SP

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


Discuss Run a DTS from a SP in the microsoft.public.sqlserver.dts forum.



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

Default Run a DTS from a SP - 12-14-2004 , 11:44 AM






What is the code to get a DTS package to run within my Stored
Procedure? I have to kick one off for a price update from an Excel
file.

TIA

__Stephen


Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Run a DTS from a SP - 12-14-2004 , 12:00 PM






In message <1103046259.382630.295610 (AT) c13g2000cwb (DOT) googlegroups.com>,
srussell705 <srussell (AT) lotmate (DOT) com> writes
Quote:
What is the code to get a DTS package to run within my Stored
Procedure? I have to kick one off for a price update from an Excel
file.

TIA

__Stephen

You can use -
xp_cmdshell to call dtsrun
OLE stored procedures to load and execute via the object model
Use sp_start_job to call an existing schedule package

Some more on the OLE stuff here-

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


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
ATJaguarX
 
Posts: n/a

Default Re: Run a DTS from a SP - 12-14-2004 , 04:34 PM



I created the following SP for the sole purpose of launching a DTS package:


CREATE PROCEDURE [dbo].[ExecuteDTSPackage]

@packageName varchar(100),
@serverName varchar(20),
@errorTypeOut char(3) = 'SYS' OUTPUT,
@errorCodeOut int =0 OUTPUT

AS

DECLARE @Object int
DECLARE @HResult int
DECLARE @ErrorSource varchar(255)
DECLARE @ErrorDescription varchar(255)
DECLARE @Procedure as varchar(100)

-- LOAD A VARIABLE WITH A NEEDED PROCEDURE CALL..
SELECT @Procedure = 'LoadFromSQLServer(' + @serverName + ', "", "", 256, ,
, , ' + @packageName + ')';
-- CREATE THE OBJECT.
EXEC @HResult = master..sp_OACreate 'DTS.package', @Object OUT;

IF @HResult <> 0
BEGIN
-- Trapping error if object not created
EXEC master..sp_OAGetErrorInfo @Object, @ErrorSource OUT,
@ErrorDescription OUT
SELECT hr=convert(varbinary(4),@HResult), Source=@ErrorSource,
Description=@ErrorDescription
RETURN
END

-- GET THE DTS PACKAGE REFRENCE.
EXEC @HResult = master..sp_OAMethod @Object, @Procedure, NULL;

IF @HResult <> 0
BEGIN
-- Trapping error if Execute failed
EXEC master..sp_OAGetErrorInfo @Object, @ErrorSource OUT,
@ErrorDescription OUT
SELECT hr=convert(varbinary(4),@HResult), Source=@ErrorSource,
Description=@ErrorDescription
RETURN
END

-- EXECUTE THE DTS PACKAGE.
EXEC @HResult = master..sp_OAMethod @Object, 'Execute';

IF @HResult <> 0
BEGIN
-- Trapping error if Execute failed
EXEC master..sp_OAGetErrorInfo @Object, @ErrorSource OUT,
@ErrorDescription OUT
SELECT hr=convert(varbinary(4),@HResult), Source=@ErrorSource,
Description=@ErrorDescription
RETURN
END
GO




"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
In message <1103046259.382630.295610 (AT) c13g2000cwb (DOT) googlegroups.com>,
srussell705 <srussell (AT) lotmate (DOT) com> writes
What is the code to get a DTS package to run within my Stored
Procedure? I have to kick one off for a price update from an Excel
file.

TIA

__Stephen


You can use -
xp_cmdshell to call dtsrun
OLE stored procedures to load and execute via the object model
Use sp_start_job to call an existing schedule package

Some more on the OLE stuff here-

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


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org




Reply With Quote
  #4  
Old   
Stephen Russell
 
Posts: n/a

Default Re: Run a DTS from a SP - 12-15-2004 , 11:16 AM





Thanks for the code. That is what I was looking for. From the earlier
posts i found the dtsrun comand line, and I used that from my C# web
app.

I will look at yours more because that is how I want to do it, SERVER
based in a single tier.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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.