我有几条记录,我刚刚复制和编辑过。
你可以在下面的图片中看出,我有2个每个FactorType,其中一个时间戳为“2014 ......”,另一个为“2100 ......”
我刚刚将它们更新为我想要的值,除了我意识到我有时间戳倒退。我希望2100年的日期记录和2100年的记录,我希望2014年。
我可以使用任何一系列SQL语句来完成此任务吗?
答案 0 :(得分:0)
update e
set ValidTo = case when e.ValidTo = '20140204' then '21000101'
when e.ValidTo = '21000101' then '20140204'
end
from [central].dbo.EstimateFactors as e
where [ComponentPart] = 'Labor Cost' and e.ValidTo in ('20140204','21000101')
编辑:嗯,不要“测试”数据库中的代码。备份到另一个物化表(select * into EstimateFactors_backup from [central].dbo.EstimateFactors where [ComponentPart] = 'Labor Cost' and ValidTo in ('20140204','21000101')
可能有效,或者根据适当的情况备份数据库)。