Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 26th, 2004, 05:33 PM
Registered User
 
Join Date: Dec 2003
Location: Miami, FL, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Running DTS package from withing a stored proc

Hi all,

I copy the following stored procedure from an article. It is supposed to run a dts package. The dts package simply exports a data set to a certain path in my network. When I run the package manually from the enterprise manager it runs succesfully. However, when I run the following stored proc., even though I don't get any errors, my file or data set is never exported. I already check my security settings and used several combinations of users/passwords that have all possible rights in SQL. Can anybody help?
Here is the stored procedure:

CREATE PROCEDURE sp_ExecuteDTSPackage
    @PkgName varchar(255)
AS

DECLARE @hr INT, @oPKG INT, @Cmd VARCHAR(1000), @RetVal INT
-- Create Package Object
EXECUTE @hr = sp_OACreate 'DTS.Package', @oPKG OUT
IF @hr <> 0
BEGIN
    PRINT ' ** Create Package Object Failed **'
    PRINT ''
    EXEC sp_OAGetErrorInfo @oPKG, @hr
    RETURN
END
-- Load the package
SET @Cmd = 'LoadFromSQLServer("(local)" ,"" ,"" ,0 , , , ,"' + @PkgName + '")'
EXEC @hr = sp_OAMethod @oPKG, @Cmd, NULL
IF @hr <> 0
BEGIN
    PRINT ' ** Load Package Failed **'
    PRINT ''
    EXEC sp_OAGetErrorInfo @oPKG, @hr
    RETURN
END
-- Execute package
EXEC @hr = sp_OAMethod @oPKG, 'Execute'
PRINT @PkgName
PRINT @RetVal
IF @hr <> 0
    BEGIN
        PRINT ' ** Execute Package Failed **'
        EXEC sp_OAGetErrorInfo @oPKG, @hr
        --RETURN
    END
ELSE
    PRINT ' ** Execute Package Succeeded **'

-- Clean up
EXEC @hr = sp_OADestroy @oPKG
IF @hr <> 0
BEGIN
    PRINT ' ** Destroy Package Failed **'
    EXEC sp_OAGetErrorInfo @oPKG, @hr
    RETURN
END
GO


  #2 (permalink)  
Old July 26th, 2004, 06:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

There is an easier way to do this, check out the dtsrun utility. This utility is a command-line prompt program that can be run using xp_cmdshell. You can read more about it in books online.

Brian
  #3 (permalink)  
Old July 27th, 2004, 05:34 PM
Registered User
 
Join Date: Dec 2003
Location: Miami, FL, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, you are right, that's easier. In any case I already figured out what the problem was. My SQL Server service was running under a local account with no access to my network. There is a good article on DTS security that covers different security scenarios (Microsoft Knowledge Base 269074).


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing DTS package from Stored Proc irfankhanpathan SQL Server DTS 2 September 28th, 2005 01:12 AM
Running stand alone DTS package Dhodie SQL Server DTS 0 September 5th, 2005 02:23 AM
Calling a T-SQL Stored proc from DTS mepancha SQL Server 2000 1 April 13th, 2005 09:12 AM
Passing Output Parm From St Proc to DTS Package lwendt33 SQL Server DTS 2 February 2nd, 2005 05:15 PM



All times are GMT -4. The time now is 08:11 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.