积极答复者
SSIS 增量提取如何应用时间戳timestamp

问题
答案
-
--drop table [t11] CREATE TABLE [dbo].[t11]( [a] [int] NOT NULL, ok timestamp ) --drop table config create table config( tablename varchar(50) not null, ok binary(8) ) GO insert into t11(a) values(1) insert into t11(a) values(2) --读取数据(第一次) select * from t11 --保存最大时间 insert into config(tablename,ok) SELECT '[dbo].[t11]',MAX(ok) FROM [dbo].[t11] ----------------------我是分割线------------------------- --新增 insert into t11(a) values(3) --读取数据(后续) select a,cast([ok] as datetime), ok from t11 where ok>(select ok from config where tablename ='[dbo].[t11]') --更新时间戳 update config set ok=(SELECT MAX(ok) FROM [dbo].[t11]) where tablename ='[dbo].[t11]' ----注意---- --不过现在不推荐使用时间戳,建议使用rowversion
family as water- 已标记为答案 Mog Liang 2011年2月22日 7:29
全部回复
-
CREATE TABLE [dbo].[t11](
[a] [int] NOT NULL,
ok timestamp
)GO
insert into t11(a) values(1)
insert into t11(a) values(2)
--第一次
SELECT [a]
,cast([ok] as datetime),
ok
FROM [test].[dbo].[t11]
--保存最大时间 1900-01-01 00:00:13.360--第二次 新增
insert into t11(a) values(3)--要批量导入目标源的数据
select a,cast([ok] as datetime),
ok from t11
where cast([ok] as datetime)>'1900-01-01 00:00:13.360'--保留此次最大时间截 1900-01-01 00:00:13.363
--如果我不想转换时间,该如何增量提取
-
--drop table [t11] CREATE TABLE [dbo].[t11]( [a] [int] NOT NULL, ok timestamp ) --drop table config create table config( tablename varchar(50) not null, ok binary(8) ) GO insert into t11(a) values(1) insert into t11(a) values(2) --读取数据(第一次) select * from t11 --保存最大时间 insert into config(tablename,ok) SELECT '[dbo].[t11]',MAX(ok) FROM [dbo].[t11] ----------------------我是分割线------------------------- --新增 insert into t11(a) values(3) --读取数据(后续) select a,cast([ok] as datetime), ok from t11 where ok>(select ok from config where tablename ='[dbo].[t11]') --更新时间戳 update config set ok=(SELECT MAX(ok) FROM [dbo].[t11]) where tablename ='[dbo].[t11]' ----注意---- --不过现在不推荐使用时间戳,建议使用rowversion
family as water- 已标记为答案 Mog Liang 2011年2月22日 7:29