running an msdb based pkg conditionally from sql agent

db042190 1,521 Reputation points
2020-08-25T12:38:52.45+00:00

hi we run 2014 std. and develop in vs 2013.

our pkgs are still in msdb, not the catalog.

i need to set up a sql agent job that runs a package every 5 minutes conditionally. The condition is based on the results of a query. I dont know if/how dtexec can be run from t-sql.

these seem to be my options...

  1. two jobs , 1st calls/starts 2nd based on condition (i know how to do this)
  2. 1 job, 2 steps, 1st step aborts if condition isnt met, i kind of like this because it could alert me to another problem
  3. conditionally exec dtexec from 1st step (t-sql) of one job but i dont know the syntax and thus far cant find it on the web
  4. control the condition from within the pkg but i hate coupling things like this in a pkg where in the future i might want to also run this pkg stand alone unconditionally in certain situations
SQL Server Integration Services
SQL Server | Other
0 comments No comments
{count} votes

9 answers

Sort by: Most helpful
  1. Yitzhak Khabinsky 27,091 Reputation points
    2020-08-28T15:41:04.3+00:00

    @db042190
    You should be able to do it by following steps below:

    1. Launch dtexecui.exe, select SSIS package, set all the parameters, etc.
    2. Go to the 'Command line' entry. you will find there what needs to be executed.
    3. Switch to SSMS, and launch there T-SQL, @SQLCmd variable value should be what you copied from the dtexecui, 'Command Line' entry: EXECUTE master.sys.xp_cmdshell @SQLCmd;
    0 comments No comments

  2. db042190 1,521 Reputation points
    2020-09-17T19:37:50.023+00:00

    thx yitzhak, in what path is dtexecui.exe?


  3. Jeffrey Williams 1,901 Reputation points
    2020-09-17T22:08:57.31+00:00

    When I am faced with this type of situation - I modify the package so it performs the necessary checks. Then just execute the package every 5 minutes. If the condition isn't met then nothing is done and the package exits. If the condition is met - the package executes and performs the work that is required.

    0 comments No comments

  4. db042192 1 Reputation point
    2020-11-08T20:38:58.997+00:00

    Hi all. I've been denied access to this forum for no apparent reason.

    If that hadn't happened I would have chosen an answer by now, Tom's first post.

    I notified/complained to the Better Business Bureau North West after ending up in a wild goose chase with MS. I'll be using a different forum since this one has been a major disappointment.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.