Is there a simple way to tell if package is running as a job?

  • Hi there.

    I am relatively new to the world of DTS programming. So far, I have been quite impressed with what it can do.

    I now have a package that processes files sitting in a source directory, loading the data into a SQL Server table.

    My question is this ... there are a number of places in the package where I use a MsgBox function to provide feedback. Typically, this only happens once when the package is completed.

    I now want to schedule the package as a job. Obviously, I don't want to use MsgBox in this case. Is there a simple way to tell if the package is being run as a job as opposed to running directly within SQL Server Enterprise Manager?

    Thanks in advance.

    - Mike

  • When the package is scheduled it creates a job. Open the job properties and in the notify tab select your method of notification.

     

    Good luck.


    Don't count what you do, do what counts.

    SQL Draggon

  • That's a good idea, thanks.

    I think I didn't word my question that well. I was considering mixing my code with Msgbox commands (to use when I running the package directly myself) and Print commands (to use when the package runs as a job). If I had some way to determine what context the package was running in, I could use a simple IF statement to decide which method of feedback to use.

    This may not be possible and I'm starting to think I should just use Print commands (or whatever) to log progress regardless of how the package runs.

  • Hi,

    You can use Global variable and when you are calling DTS package from the job you can specify different value for this variable using parameter /~A in DTSRUN command.

    Otakar


    Otakar

  • Mike,

    There is no way that the package can know where it has been executed from (which is what you are asking). However you can TELL it where it is being executed from which is exactly what Otakar has suggested. His approach would be my approach.

     

  • Thanks for the tips.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply