Lorem ipsum dolor sit amet, consectetur adipiscing elit. Test link

Cập nhật 2 bảng SQL Server thông qua thời gian xấp xỉ giá tị giây (s)

Cập nhật 2 bảng SQL Server

 


Cập nhật 2 bảng dữ liệu Sql Server




SELECT top  1000

a.Id,

 a.CreateTime,

 a.DateTime2,

 a.Weight1,

 a.Weight2,

a.A3WeighVoucher0Id as A3WeighVoucher0Id ,

a.A3WeighVoucher1Id as A3WeighVoucher1Id ,

null as 'cột' ,


b.Id as b_A3WeighVoucher0Id,

c.Id as  A3WeighVoucher1Id


FROM [AMMS].[dbo].[A3WeighVoucher2]  a

left join A3WeighVoucher0  b on    ABS(DATEDIFF(second, a.CreateTime, b.CreateTime)) < 4

left join A3WeighVoucher1  c  on    ABS(DATEDIFF(second, a.CreateTime, c.CreateTime)) < 4

--update  [A3WeighVoucher2] set 

where 

a.A3WeighVoucher1Id = 'E4BBDAF6-0E96-4FE5-A26D-D16F2FFA8B29'

order by a.CreateTime DESC


-- B75822EF-352B-4358-ACE1-48322BACD2FA



UPDATE  A3WeighVoucher2  set A3WeighVoucher2.A3WeighVoucher1Id = A3WeighVoucher1.Id


FROM A3WeighVoucher2 

left join A3WeighVoucher0    on    ABS(DATEDIFF(second, A3WeighVoucher2.CreateTime, A3WeighVoucher0.CreateTime)) < 3 

left join A3WeighVoucher1     on    ABS(DATEDIFF(second, A3WeighVoucher2.CreateTime, A3WeighVoucher1.CreateTime)) < 3

--update  [A3WeighVoucher2] set 

where A3WeighVoucher2.A3WeighVoucher1Id = 'E4BBDAF6-0E96-4FE5-A26D-D16F2FFA8B29'  

Đăng nhận xét

© Lưu Đức Huy IT. All rights reserved. Premium By Raushan Design