Results 1 to 7 of 7

Thread: Sort Table

  1. #1
    Join Date
    Sep 2005
    Location
    Brooklyn, ny
    Posts
    69

    Unanswered: Sort Table

    Hello,
    Is there a way to re sort data in a table? based on ID.

    The
    SORT TABLE tlb_Name ON ID Asc
    is not working?

    Thank you very much.

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    how about a clustered index?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Sep 2005
    Location
    Brooklyn, ny
    Posts
    69
    I had to recreate my index to unq. clustered and it worked like a charm. Thank you.

    LP

  4. #4
    Join Date
    Jan 2004
    Location
    Tacoma, Wa
    Posts
    15

    Sorted data?

    It may be just me, but I'm always a little hesitant to think of data in a table as 'sorted'. For most vendors, data retrieved using the clustered index comes back in the order of the index, but 'order by' is the only way to guarantee you'll get the data in the order you want. If the vendor implementation changes tomorrow, and you're counting on a particular order and you haven't explicitly asked for that order, you're out of luck.

  5. #5
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    yes yes as brett will tell you the order of the data in the database has no meaning but I am pretty sure if you do a select * on a table in sql 2k and 7 you will recieve the data in the order of the clustered index. plus encouraging this guy to use one is preferable to him having a heap laying around. sounds like he might really want is a clustered primary key.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  6. #6
    Join Date
    Jan 2004
    Location
    Tacoma, Wa
    Posts
    15
    Yep, it works that way in Sybase, too (though I seem to remember something about rows returned from parallel scans not adhering to the pattern unless 'order by' was specified).

    I just think that he needs to understand why it works and the risk he's taking if he doesn't actually specify the order. I don't want to be the one to guarantee that the MS boys up the road in Redmond will ALWAYS implement it that way.

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Just because the data happens to be stored in the order of the clustered index is no guarantee it will be returned or processed in that order, and should not be used a substitute for ORDER BY clauses.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •