原文地址http://sqljunkies.com/WebLog/knight_reign/archive/2005/02/27/8187.aspx
Here's something useful you can do with system variables and the SQL Task. Logging in SSIS is more flexible and there are more options for logging destinations and formats then with DTS. However, it may not always be as surgical as you'd like it to be, and you can only create log events that the components support.

  • You can use a script component or task and log custom log events “on the fly“. This has value in some cases.
  • You can create a custom task in which you can create custom log events that you may actually filter. I think there is someone writing one of these now. :)
  • You can build a pipeline to output to various formats.
  • You can use the SQL Task to log custom data using parameter mapping and variables.

I've created a very simple package run log that illustrates the last option. Granted, the package already logs a similar set information, but it's a good example because it's easy to compare the two approaches. Using the SQL Task, I have created a simple log table that logs the username, packagename, machinename, packageID and starttime for each time a package gets executed.

First, I created a table as follows.

use Playland
CREATE TABLE PackageRun (
username varchar(50),
packagename varchar(50),
machinename varchar(50),
packageID varchar(50),
starttime datetime
);

Then in the SQL Task, I have the following insert statement:

INSERT INTO PackageRun VALUES(?,?,?,?,?);
/* username    varchar(50),
packagename varchar(50),
machinename varchar(50),
packageID   varchar(50),
starttime   date */

Here's where the system variables come in handy. The Parameter Mapping tab looks like this:

I've put this SQL Task in the package at package scope to log simple information about the run of the package. Now, whenever I run the package, it enters a log into the PackageRun table as shown below.

Existing log events cover a lot of ground. The logging infrastucture generously handles the general case for logging, but it's a broad brush and doesn't always get as detailed as you'd like. There are cases where there is no way to log specific information. For example, parameters to event handlers, the LocaleID of a specific container and task execution values. This logging mechanism can be used for just about any type of custom logging you'd like at anytime during the execution of the package and is great for one off, surgical logging of custom data that the existing log infrastructure doesn't support. If you ever run into the situation where you wished something got logged, but it doesn't, this method may fill in the gaps.

Let me know if this was useful to you.

Thanks,
Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden

转载于:https://www.cnblogs.com/stu-acer/archive/2008/01/23/1050675.html

System variables, logging and the Execute SQL Task...(zz)相关推荐

  1. Execute SQL Task 参数和变量的映射

    Execute SQL Task能够执行带参数的SQL查询语句或存储过程(SP),通过SSIS的变量(Variable)对参数赋值.对于不同的Connection Manager,在Task中需要使用 ...

  2. SSIS Execute SQL Task assign output 的两种方法

    按一个SQL语句select count(1) from tmp为例. 可以用: 1.存储过程+Output参数 2.SQL语句+result set ------------------------ ...

  3. SSIS Execute SQL Task 用法

    Execute Sql Task组件是一个非常有用的Control Flow Task,可以直接执行SQL语句,例如,可以执行数据更新命令(update,delete,insert),也可以执行sel ...

  4. Execute Process Task

    Execute Process Task 用于在Control Flow中执行应用程序,常用于对加密的数据进行解压. 1,RequireFullFileName 属性:是否需要完整的文件路径,如果在F ...

  5. Could not execute SQL statement.

    组件 版本 Flink 1.12 Mysql 8.0.22-0ubuntu0.20.04.2 Flink SQl遇到下面的报错 [ERROR] Could not execute SQL statem ...

  6. system var mysql_MySQL 系统变量(system variables)

    MySQL系统变量(system variables)实际上是一些系统参数,用于初始化或设定数据库对系统资源的占用,文件存放位置等等.这些个系统变量可以分为全局以及会话级别层面来修改,有些也可以进行动 ...

  7. 利用Vector CANOE/CANalyzer的系统变量System Variables观察CAN信号之间的关系

    利用CANOE/CANalyzer添加"系统变量(System Variables)",进行CAN信号之间的"加减乘除"运算,协助分析CAN信号之间的差异,给工 ...

  8. MySQL 系统变量(system variables)

    MySQL系统变量(system variables)实际上是一些系统参数,用于初始化或设定数据库对系统资源的占用,文件存放位置等等.这些个系统变量可以分为全局以及会话级别层面来修改,有些也可以进行动 ...

  9. 安装鸿蒙开发工具提示Error: Cause: Failed to execute the task

    安装鸿蒙开发环境DevEco Studio 3.0.0.800,安装很顺利,安装完毕,启动的时候需要安装sdk,结果报错了 Error: Cause: Failed to execute the ta ...

最新文章

  1. Python字符串类型及操作总结
  2. virus.win32.parite.H病毒的查杀方法
  3. Mysql学习总结(14)——Mysql主从复制配置
  4. shell特殊符号cut命令 sort_wc_uniq命令 tee_tr_split命令 shell特殊符号
  5. CentOS6.x下配置sendmail发邮件
  6. java两字符串是否相等_Java与JavaScript中判断两字符串是否相等的区别
  7. 【H2 Database】查看帮助信息
  8. 使用Java RMI时要记住的两件事
  9. laravel5.1 基于redis实现任务队列
  10. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_09 序列化流_4_transient关键字_瞬态关键字...
  11. 职业规划报告!草草了事,看看得了
  12. 下载频道2013上半年超人气精华资源汇总
  13. 有关Idea的Invalidate Caches/Restart
  14. Android Studio 录屏/电脑实时显示手机的画面
  15. 启用系统保护是灰色的#win10系统
  16. 汕头示范新品种技术 国稻种芯·中国水稻节:广东水稻粒粒归仓
  17. Mac air苹果笔记本安装Win10双系统教程(绝对能成功,超详细!)[转]
  18. 若依前后端分离版本集成CAS Server5.3
  19. 比特大陆内部究竟发生了什么?
  20. python整合selenium爬取QQ空间访客记录

热门文章

  1. 看以色列话剧《安魂曲》(图)
  2. 为什么手机联系人里有permission_为什么有人在咖啡馆里不看手机不看电脑没有同伴,独自喝咖啡?...
  3. python波峰波谷算法_波动均分算法
  4. 安卓ps2模拟器_安卓PSP模拟器评测:合金装备 和平步行者
  5. Catlike Coding网站文章解析 -- 2.Procedural Grid
  6. Unity3D研究院之获取摄像机的视口区域
  7. 误差error,偏置bias,方差variance的见解
  8. 国外少儿PYTHON编程书推荐
  9. Sublime Text官方文档 中英文版本
  10. 拒绝CPU挖矿矿工有责