如何更新表中的 n 行? [英] How do I update n rows in a table?
本文介绍了如何更新表中的 n 行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要更新满足条件的表中的前 N 行.
I need to update the first N rows in a table meeting a condition.
我知道我可以做一个更新前 N 个...但问题是 N 在一个@variable 中.
I know I can do an Update Top N... but the problem is that N is in a @variable.
UPDATE TOP @N SET ... 不起作用.
UPDATE TOP @N SET ... doesn't work.
有没有办法做到这一点,我只是想念?
Is there a way to do this that I am just missing?
这里没有特定的表定义,因为列是什么并不重要..如果我可以为单列表执行此操作,我也可以为我的表执行此操作.
No specific table definitions here because it doesn't matter what the columns are.. If I can do it for a one column table I can do it for my table.
推荐答案
当你想使用一个变量时,你需要在 TOP
子句之后使用括号:
You need to use parens after TOP
clause when you want to use a variable:
UPDATE TOP(@N) ...
这篇关于如何更新表中的 n 行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文