Results 1 to 8 of 8

Thread: Execute DTS from a Procedure

  1. #1
    Join Date
    Jan 2009
    Posts
    5

    Execute DTS from a Procedure

    Hello,

    I am trying to run a DTS Package from a stored procedure. But when I execute the procedure
    from the Query Analyzer, the procedure never completes. Here is the code for executing the
    DTS package.

    --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, 'LoadFromSQLServer("myDB","","",256,,,, "OVCF")',
    NULL
    IF @hr <> 0
    BEGIN
    print 'error LoadFromStorageFile'
    RETURN
    END

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

    If I comment out the last part (Execute of the object), the procedure runs fine. I need your help
    in figuring out what I need to do.

    Thanks

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    The other way around is creating sql job to run dts package then you starting job in sp.

  3. #3
    Join Date
    Jan 2009
    Posts
    5
    Can you give me the code to run the sql job in a procedure.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    msdb..sp_start_job

  5. #5
    Join Date
    Jan 2009
    Posts
    5
    I am running the msdb..sp_start_job @job_name = 'OF'.
    I get the message that the DTS is running, but I am not getting
    the any results from the DTS. If I try to run the DTS package
    manually, I get the error that the package is running.

    Is there a way I can get a return if there is an error? Do you have any examples where this has worked?

    Thanks

  6. #6
    Join Date
    Sep 2002
    Posts
    5,938
    Sounds issue in your package. Enable package logging to find out what's wrong first.

  7. #7
    Join Date
    Jan 2009
    Posts
    5
    I am able to run the DTS package and it works fine. It is when I try to run the Scheduled Job that nothing happens.

    Do I need additional permissions to run the sql job?

    Thanks

  8. #8
    Join Date
    Sep 2002
    Posts
    5,938
    What does the package do? If remote files or so involved, ensure sql service accounts have permission to access them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •