如何使用ABS,DATEDIFF更新多个列

时间:2017-09-22 07:03:30

标签: sql sql-server database datediff dbm

DECLARE 

@deviationtime int,
@actualtime datetime,
@estimatedtime datetime


While (Select TOp 1 successrate FROM YBS_Tahmin_Kayit where deviationtime = 999 order  by recordtime desc) = 999
    BEGIN 

    SET @actualtime= (SELECT Top 1 actualtime From [TTS].[dbo].YBS_Tahmin_Kayit where deviationtime = 999  order by recordtime Desc  )
    SET @estimatedtime =        (SELECT Top 1 estimatedtime From [TTS].[dbo].YBS_Tahmin_Kayit where deviationtime = 999 order by recordtime Desc  )



        SET @deviationtime = ABS(DATEDIFF(second, @actualtime, @estimatedtime))



    Update [TTS].[dbo].YBS_Tahmin_Kayit SET deviationtime = @deviationtime where deviationtime = 999 and estimatedtime= @estimatedtime

    end

我在数据库中设置了所有偏差时间= 999。

我希望从数据库更新所有偏差时间,但我的代码逐一进行。

0 个答案:

没有答案