日期:2014-05-18 浏览次数:20427 次
DECLARE @timestamp DATETIME UPDATE TAB SET @timestamp = CASE WHEN @timestamp IS NULL THEN timestamp ELSE DATEADD(SECOND,1,@timestamp) END ,timestamp = @timestamp
------解决方案--------------------
--> 测试数据:[test] if object_id('[test]') is not null drop table [test] create table [test]([id] int,[timestamp] datetime) insert [test] select 1,'2012-5-4 17:07:35' union all select 2,'2012-5-4 17:07:35' union all select 3,'2012-5-4 17:07:35' update test set [timestamp]=DATEADD(DD,id-1,(select [timestamp] from test where id=1)) select * from test /* id timestamp 1 2012-05-04 17:07:35.000 2 2012-05-05 17:07:35.000 3 2012-05-06 17:07:35.000*/