I need to update the first N rows in a table meeting a condition.
I know I can do an Update Top N... but the problem is that N is in a @variable.
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.
You need to use parens after TOP
clause when you want to use a variable:
UPDATE TOP(@N) ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With