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
 Old Forums
 CLOSED - General SQL Server
 TOP n

Author  Topic 

Listen
Starting Member

44 Posts

Posted - 2004-03-18 : 02:53:52
Is there a possibility on how to update TOP n records just like in SELECT statement?

Say, I have 20 records and I just need to update the first 5. How?

Thanks.

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-03-18 : 02:58:51
First select the top 5 records into a Temp Table and then update the original Table by joining to this temp table.

Duane.
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-03-18 : 03:02:16
Listen, from a few of your posts I'm picking up a bit of a trend.

Inside a relational database, the "order" of rows is not guaranteed and shouldn't be thought about.

You can pull data out in a certain order, but there is no such thing as "the first 5" rows internally.

There is no concept of a Rowid in SQL Server, you can give a row an identity value, but that doesn't necessarily determine any sort of physical order.

Does that make sense ?



Damian
Go to Top of Page
   

- Advertisement -