SSIS: 使用最大ID和最大日期来增量更新表

简单三步:

1.  新增变量 MaxID和MaxCreateDate以及Variable

image

2.  放置一个 Execute SQL  Task ,用SQL 来获取 MaxID和MaxCreateDate ,并设置Result Set

SELECT  MaxCreatedDate = CONVERT(NVARCHAR(255), COALESCE(MAX(created_at),
                                                         '19900101'), 121) ,
        MaxID = MAX(id)
FROM    http_requests

image

image

3. 点击Data Flow Task, 在属性框中找到 Expressions.点击’…’打开对话框.然后将SqlCommand 替换为变量Variable.

Variable变量通过MaxID和MaxCreateDate获得的值来拼接SQL

"select * from http_requests where created_at >'" +  @[User::MaxCreatedDate]+"'" +" and id >" +  @[User::MaxID]

image

posted @ 2015-03-31 11:24  Haseo  阅读(2059)  评论(0编辑  收藏  举报