--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]'