title: How to check if SSIS package called by T-SQL running finished
body: <p>I want to USE SSIS package to ETL data for a several days, I wrote some T-SQL to invoke the SSIS package, the principle is the ETL for the first day finished then can work on the second day ...</p>
  
  <p>The below "Execute SQL task" component is under a for loop container and the SQL like this:    </p>
  
  <pre><code>Declare @execution_id bigint
  EXEC [SSISDB].[catalog].[create_execution] @package_name=N'MAIN.dtsx', @execution_id=@execution_id OUTPUT, @folder_name=N'RE_RUN_LOGIC_DEMO', @project_name=N'BUSINESS_ETL_STEVEN', @use32bitruntime=False, @reference_id=Null
  Select @execution_id
  DECLARE @var0 smallint = 1
  EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id,  @object_type=50, @parameter_name=N'LOGGING_LEVEL', @parameter_value=@var0
  EXEC [SSISDB].[catalog].[start_execution] @execution_id
  
  --WAITFOR DELAY '00:00:07.000'    
  </code></pre>
  
  <p>The problem is if I comment out the last line for the above code, the ETL works not as expected, I have to add the WAITFOR statement, this is just a demo, but in the real project, I don't know how much time the SSIS package invoked by the above T-SQL will spend, so I don't think WAITFOR DELAY is a good solution, for this example, is there a way to check if the SSIS package is finished or not in T-SQL, so that I can write some other code after it but depends on above SSIS package running finished, for example, execute some procedures or invoke some other SSIS packages.</p>