本文介绍了如何将 ROW_NUMBER() 分配给一列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
阅读这个问题后,我还有一个类似的问题.有没有一种简单的方法可以让这个 SQL 语句起作用?
After reading this question, I have another similar question. Is there a simple way to get this SQL statement to work?
update [Insurances] set [RowNo]=ROW_NUMBER() over (order by [RowNo])
我有一个 RowNo
列,我想在删除记录时更新该列.
I have a RowNo
column which I want to update whenever a record is deleted.
推荐答案
UPDATE t1
SET t1.RowNo = s.RowNo
FROM [Insurances] t1
INNER JOIN
(
SELECT Id, ROW_NUMBER() OVER( ORDER BY Somefield DESC) RowNo
FROM Insurances
) s ON t1.Id = s.Id
这篇关于如何将 ROW_NUMBER() 分配给一列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!