Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Rows not in order in 2005

Rows not in order in 2005

Scheduled Pinned Locked Moved Database
databasehelptutorialquestionlounge
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ramyasangeet
    wrote on last edited by
    #1

    hi all, I am working in sql 2005 migration. when i ran same query in sql 2000 and sql 2005,no of values return are same.But the Resulting data is in different order. In sql 2005 the data returns either in asc or desc order. In sql 2000 the data returns in random order. plz clarify me 1.the reason for the rows order difference.(is it because of execution plan?) 2.The resulting data of sql2005 should be in same order of sql 2000. how to overcome this problem. Thanks in advance,

    cheers sangeet

    S C 2 Replies Last reply
    0
    • R ramyasangeet

      hi all, I am working in sql 2005 migration. when i ran same query in sql 2000 and sql 2005,no of values return are same.But the Resulting data is in different order. In sql 2005 the data returns either in asc or desc order. In sql 2000 the data returns in random order. plz clarify me 1.the reason for the rows order difference.(is it because of execution plan?) 2.The resulting data of sql2005 should be in same order of sql 2000. how to overcome this problem. Thanks in advance,

      cheers sangeet

      S Offline
      S Offline
      SimulationofSai
      wrote on last edited by
      #2

      ramyasangeet wrote:

      1.the reason for the rows order difference.(is it because of execution plan?)

      The order in which the rows are returned is determined by a lot of factors, clustered index, page placements, row order etc. For example, if there's a clustered index on the table, the optimizer will find it cheaper to return rows in the index order. Also, the query engine has undergone vast changes in 2005 compared to 2000.

      ramyasangeet wrote:

      2.The resulting data of sql2005 should be in same order of sql 2000.

      Use an Order by clause.

      SG Cause is effect concealed. Effect is cause revealed.

      1 Reply Last reply
      0
      • R ramyasangeet

        hi all, I am working in sql 2005 migration. when i ran same query in sql 2000 and sql 2005,no of values return are same.But the Resulting data is in different order. In sql 2005 the data returns either in asc or desc order. In sql 2000 the data returns in random order. plz clarify me 1.the reason for the rows order difference.(is it because of execution plan?) 2.The resulting data of sql2005 should be in same order of sql 2000. how to overcome this problem. Thanks in advance,

        cheers sangeet

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        As the previous poster said, if you want a specific order then use the order by clause. Do not rely on the intrinsic order that SQL Server uses as it can, as you've seen, be non-deterministic.


        Upcoming FREE developer events: * Developer Day Scotland My website

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups