SQL Update TOP 、Update Order by 和output的使用

update top(1) Products with(updlock,readpast)
set Status = 1
output Deleted.Id as PoolSkuId
from 
(select top 1 Id from Products 
where Deleted = 0 and Status = 0 order by createdTime desc) t1
where Products.Id = t1.Id

  

posted @ 2020-06-22 21:45  微笑代表淡定.Net  阅读(612)  评论(0编辑  收藏  举报