Usage of the TOP clause

  • I just wanted to retrieve the first ten rows in the table. have been trying to use the Top clause but Im not getting the expected result.

    Im a new baby using the SQL server 08.

  • Does your query also have an Order By clause? If not, Top can/will do strange things.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • SELECT TOP (10) <column list>

    FROM <Some Table>

    ORDER BY <Whatever columns defines the ordering you want>

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (6/6/2011)


    SELECT TOP (10) <column list>

    FROM <Some Table>

    ORDER BY <Whatever columns defines the ordering you want>

    Thanks it has been useful

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply