在TSQL中执行SSIS程序包

编程入门 行业动态 更新时间:2024-10-27 10:18:45
本文介绍了在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 32位 版权(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程序包

本文发布于:2023-07-15 10:34:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1110694.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序包   TSQL   SSIS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!