在TSQL中执行SSIS程序包 [英] Executing SSIS Package in TSQL

查看:146
本文介绍了在TSQL中执行SSIS程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,专家,

我有dts包,可以生成报告到接受输入参数的单位.问题是,尽管它执行并成功创建了报表,但它没有生成我想要的输出.它应该提取180但只生成87.

以下是我的TSQL查询

use pos
declare @tempTpaID varchar(50)
--Cursor to scan each tpaid
declare scanTpaID cursor read_only
for	
	select distinct tpaid from transaction_header
	where tpaid=''1517''
	--select tpaid,bccode from transaction_header
	
--open the cursor
open scanTpaID

--set the tempTPAID
fetch next from scanTpaID
	into @tempTpaID

while @@fetch_status=0
begin
	
	--print @tempTpaID
	
	declare @cmd nvarchar(200)


	set @cmd = ''dtexec.exe /F "C:\Test\UploadFile.dtsx" /de "atms"  /Set \Package.Variables[User::tpaVal].Value\;''
	declare @cmd2 nvarchar(200)= @cmd + ''"'' +@tempTpaID + ''"''
	--print @cmd2
	EXEC xp_cmdshell @cmd2;

	--fetch value again to set another tpa
	fetch next from scanTpaID
	into @tempTpaID
	 
end

close scanTpaID

deallocate scanTpaID




以下也是查询的日志

  Microsoft (R) SQL  服务器 执行 包装 实用程序
版本  10 . 50 . 1600 . 1   for  版权(C) Microsoft  公司  2010 . 所有 权利 已保留.
 NULL 
开始:  10:20:22   AM 
进度:  2012-09-18   10:20:23 . 14 
   来源: 生成 详细信息 上传 文件
   验证: 0%完成
结束 进度
进度:  2012-09-18   10:20:23 . 27 
   来源: 生成 详细信息 上传 文件
   验证: 50%完成
结束 进度
进度:  2012-09-18   10:20:23 . 28 
   来源: 生成 详细信息 上传 文件
   验证: 100%完成
结束 进度
进度:  2012-09-18   10:20:23 . 28 
   来源: 生成 详细信息 上传 文件
   验证: 0%完成
结束 进度
进度:  2012-09-18   10:20:23 . 33 
   来源: 生成 详细信息 上传 文件
   验证: 50%完成
结束 进度
进度:  2012-09-18   10:20:23 . 33 
   来源: 生成 详细信息 上传 文件
   验证: 100%完成
结束 进度
警告:  2012-09-18   10:20:23 . 33 
   代码:  0x80049304 
   来源: 生成 详细信息 上传 文件  SSIS .描述: 警告: 可以 打开 全局 内存 进行通信 带有 性能 DLL; 数据  性能  可用.  解决运行    as    管理员  系统的控制台.
结束 警告
进度:  2012-09-18   10:20:23 . 33 
   来源: 生成 详细信息 上传 文件
   准备 准备 执行: 0%完成
结束 进度
进度:  2012-09-18   10:20:23 . 33 
   来源: 生成 详细信息 上传 文件
   准备 准备 执行: 50%完成
结束 进度
进度:  2012-09-18   10:20:23 . 33 
   来源: 生成 详细信息 上传 文件
   准备 准备 执行: 100%完成
结束 进度
进度:  2012-09-18   10:20:23 . 34 
   来源: 生成 详细信息 上传 文件
   预执行: 0%完成
结束 进度
进度:  2012-09-18   10:20:23 . 41 
   来源: 生成 详细信息 上传 文件
   预执行: 50%完成
结束 进度
进度:  2012-09-18   10:20:23 . 41 
   来源: 生成 详细信息 上传 文件
   预执行: 100%完成
结束 进度
进度:  2012-09-18   10:20:23 . 43 
   来源: 生成 详细信息 上传 文件
   发布 执行: 0%完成
结束 进度
进度:  2012-09-18   10:20:23 . 43 
   来源: 生成 详细信息 上传 文件
   发布 执行: 50%完成
结束 进度
进度:  2012-09-18   10:20:23 . 46 
   来源: 生成 详细信息 上传 文件
   发布 执行: 100%完成
结束 进度
进度:  2012-09-18   10:20:23 . 46 
   来源: 生成 详细信息 上传 文件
   清理: 0%完成
结束 进度
进度:  2012-09-18   10:20:23 . 46 
   来源: 生成 详细信息 上传 文件
   清理: 50%完成
结束 进度
进度:  2012-09-18   10:20:23 . 46 
   来源: 生成 详细信息 上传 文件
   清理: 100%完成
结束 进度
 DTExec:   软件包 执行    DTSER_SUCCESS (0).
开始:  10:20:22   AM 
完成:  10:20:23   AM 
已使用:  0 . 468  
 NULL  




谢谢,
Dan

解决方案

我认为问题在于Cusror不等待每个包执行完成.我建议您使用For Each容器在一个包中完成所有这些操作:例如:
在SSIS中使用Foreach ADO枚举器 [ ^ ]

Hi experts,

I have dts package that generate report to flat that accepts input parameter. The problem is although it execute and successfully create the report it does not generate my desired output. Wherein it supposed to extract 180 but just generate 87.

Below is my TSQL query

use pos
declare @tempTpaID varchar(50)
--Cursor to scan each tpaid
declare scanTpaID cursor read_only
for	
	select distinct tpaid from transaction_header
	where tpaid=''1517''
	--select tpaid,bccode from transaction_header
	
--open the cursor
open scanTpaID

--set the tempTPAID
fetch next from scanTpaID
	into @tempTpaID

while @@fetch_status=0
begin
	
	--print @tempTpaID
	
	declare @cmd nvarchar(200)


	set @cmd = ''dtexec.exe /F "C:\Test\UploadFile.dtsx" /de "atms"  /Set \Package.Variables[User::tpaVal].Value\;''
	declare @cmd2 nvarchar(200)= @cmd + ''"'' +@tempTpaID + ''"''
	--print @cmd2
	EXEC xp_cmdshell @cmd2;

	--fetch value again to set another tpa
	fetch next from scanTpaID
	into @tempTpaID
	 
end

close scanTpaID

deallocate scanTpaID




Below as well is the logs of the query

Microsoft (R) SQL Server Execute Package Utility
Version 10.50.1600.1 for 32-bit
Copyright (C) Microsoft Corporation 2010. All rights reserved.
NULL
Started:  10:20:22 AM
Progress: 2012-09-18 10:20:23.14
   Source: Generate Detail Upload File
   Validating: 0% complete
End Progress
Progress: 2012-09-18 10:20:23.27
   Source: Generate Detail Upload File
   Validating: 50% complete
End Progress
Progress: 2012-09-18 10:20:23.28
   Source: Generate Detail Upload File
   Validating: 100% complete
End Progress
Progress: 2012-09-18 10:20:23.28
   Source: Generate Detail Upload File
   Validating: 0% complete
End Progress
Progress: 2012-09-18 10:20:23.33
   Source: Generate Detail Upload File
   Validating: 50% complete
End Progress
Progress: 2012-09-18 10:20:23.33
   Source: Generate Detail Upload File
   Validating: 100% complete
End Progress
Warning: 2012-09-18 10:20:23.33
   Code: 0x80049304
   Source: Generate Detail Upload File SSIS.Pipeline
   Description: Warning: Could not open global shared memory to communicate with performance DLL; data flow performance counters are not available.  To resolve, run this package as an administrator, or on the system's console.
End Warning
Progress: 2012-09-18 10:20:23.33
   Source: Generate Detail Upload File
   Prepare for Execute: 0% complete
End Progress
Progress: 2012-09-18 10:20:23.33
   Source: Generate Detail Upload File
   Prepare for Execute: 50% complete
End Progress
Progress: 2012-09-18 10:20:23.33
   Source: Generate Detail Upload File
   Prepare for Execute: 100% complete
End Progress
Progress: 2012-09-18 10:20:23.34
   Source: Generate Detail Upload File
   Pre-Execute: 0% complete
End Progress
Progress: 2012-09-18 10:20:23.41
   Source: Generate Detail Upload File
   Pre-Execute: 50% complete
End Progress
Progress: 2012-09-18 10:20:23.41
   Source: Generate Detail Upload File
   Pre-Execute: 100% complete
End Progress
Progress: 2012-09-18 10:20:23.43
   Source: Generate Detail Upload File
   Post Execute: 0% complete
End Progress
Progress: 2012-09-18 10:20:23.43
   Source: Generate Detail Upload File
   Post Execute: 50% complete
End Progress
Progress: 2012-09-18 10:20:23.46
   Source: Generate Detail Upload File
   Post Execute: 100% complete
End Progress
Progress: 2012-09-18 10:20:23.46
   Source: Generate Detail Upload File
   Cleanup: 0% complete
End Progress
Progress: 2012-09-18 10:20:23.46
   Source: Generate Detail Upload File
   Cleanup: 50% complete
End Progress
Progress: 2012-09-18 10:20:23.46
   Source: Generate Detail Upload File
   Cleanup: 100% complete
End Progress
DTExec: The package execution returned DTSER_SUCCESS (0).
Started:  10:20:22 AM
Finished: 10:20:23 AM
Elapsed:  0.468 seconds
NULL




Thanks,
Dan

解决方案

I think the problem is Cusror does not wait for each package execution to completed. I would suggest a you do all this in a package using For Each container: For example:
Using the Foreach ADO Enumerator in SSIS[^]


这篇关于在TSQL中执行SSIS程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆