Hi,
I have a table in SQL with a column Name(varchar(50)) only. There are 100 records . There are names like as A, B & C. Suppose there are 30 Name like A, 30 Name like B and 40 are like C.
Names are like as in my sql table:
a
a
a
a
a
a
a
a
b
b
c
a
b
a
c
c
a
b
.....
Then I want to update only 5 starting rows(which contain Name A) as B.
How to update only starting 5 rows???
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


rajat kumar56 reputationPosted Mar 2, 2015, 2:28 AM EST
WITH q AS ( SELECT TOP (@r) * FROM mytable ORDER BY col1 ) UPDATE q SET co12 = @valuePankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Mar 2, 2015, 2:42 AM EST
Anurag Singh131 reputationPosted Mar 2, 2015, 2:50 AM EST
Your query is working fine.