Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

exec ssis package as from SP throws error "peer connection closed prematurely" but works when run as job or manually

$
0
0

Hi,

I have a SSIS package which has OLEDB connection to tabular model query and dumps the data into table and transforms the data for business needs.There are package parameters .I ran the package as a SQL job and in VS ,it works fine.But when i execute this as a SP ,i get very strange error like "the peer closed connection prematurely".This is the connection that points to tabular model.

What could be causing this and what needs to be changed.Below is the script:

/****** Object:  StoredProcedure   Script Date: 6/29/2020 23:12:41 ******/

create proc [dbo].[RefreshOnDemand](@Yrmonth nvarchar(100),@RefreshedBy nvarchar(100)) as

declare @my_execution_id bigint

declare @my_folder_name varchar(255)= 'Inventory'
declare @my_project_name varchar(255) = 'Inventory'
declare @my_package_name varchar(255) = 'RefreshData.dtsx'
declare @StartDate nvarchar(100),@EndDate nvarchar(100)

set @StartDate=(select concat(@Yrmonth , '-01' ,'T00:00:00' ))
set @EndDate=(select concat( EOMONTH(@StartDate),'T00:00:00'))


--First create Execution and get ExecutionID in a variable

exec [SSISDB].[catalog].[create_execution]
@folder_name = @my_folder_name
,@project_name = @my_project_name
,@package_name = @my_package_name
,@reference_id = null
,@execution_id = @my_execution_id output


--Wait until package execution is done
EXEC [SSISDB].[catalog].set_execution_parameter_value
@my_execution_id,  
@object_type=50, 
@parameter_name=N'SYNCHRONIZED', 
@parameter_value=1

--Set package parameters
exec [SSISDB].[catalog].set_execution_parameter_value  @my_execution_id, 30, 'Month_to_delete', @Yrmonth  
exec [SSISDB].[catalog].set_execution_parameter_value  @my_execution_id, 30, 'Scheduled_StartDate', @StartDate 
exec [SSISDB].[catalog].set_execution_parameter_value  @my_execution_id, 30, 'Scheduled_EndDate', @EndDate
exec [SSISDB].[catalog].set_execution_parameter_value  @my_execution_id, 30, 'WhoTrigerred', @RefreshedBy

--Start Execution
exec [SSISDB].[catalog].start_execution @my_execution_id

-- Check package status, and fail script if the package failed
IF 7 <> (SELECT [status] FROM [SSISDB].[catalog].[executions] WHERE execution_id = @my_execution_id)
RAISERROR('The package failed. Check the SSIS catalog logs for more information', 16, 1)


Viewing all articles
Browse latest Browse all 24688


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>