This website requires JavaScript.

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](http://images.cnitblog.com/blog/378031/201503/311123469202269.png "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](http://images.cnitblog.com/blog/378031/201503/311123494048609.png "image")
0条评论
avatar