I have 20 rows in a table and I want to update 10 of them only.
I am using MS SQL.
Any ideas please.
update tablename set col1='newvalue' where col2='my condition'
use below procedure
WHERE Sal>=5000 and sal<=15000
IF @@ROWCOUNT = 10
PRINT 'Count limit is reached.';
Thanks for the suggestion.
There are 3 columns. But as you know the very first column is nameless and numbers each row. I cannot use a any of the columns to set a condition e.g. if col1 < 'value1' and > 'value2'. I just want to be able to update 2 columns values up to 10 rows.
Hope that makes sense.
Thanks for the help
Can you use the IF @@ROWCOUNT = 10 without the WHERE condition?
update top(10) MyTable set MyColumn = 22
Update EMPLOYEE set EMPNAME='SomeValue' where EMPID in(1,2,3,4,5,6,7,8,9,10)