Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 issue updating top 10 rows

Author  Topic 

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2005-05-05 : 04:55:02
How can I update only the top 10 rows only.Is there any way to do this?

mr_mist
Grunnio

1870 Posts

Posted - 2005-05-05 : 04:57:45
What do you mean the top 10 rows? Top has no meaning in a relational database unless you apply an order.

-------
Moo. :)
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-05-05 : 04:59:24
and you can't do that in an update.

i kind of thinking you want to use
set rowcount 10


Go with the flow & have fun! Else fight the flow
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2005-05-05 : 05:12:50
You could probably do something like


UPDATE yourtable SET yourvalue = Whatever WHERE yourkeycolumn IN (SELECT TOP 10 yourkeycolumn FROM yourtable ORDER BY yourkeycolumn)


-------
Moo. :)
Go to Top of Page

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2005-05-05 : 13:57:16
Thanks.......this should work
Go to Top of Page
   

- Advertisement -