Results 1 to 3 of 3

Thread: Wrong 'Order By'

  1. #1
    Join Date
    May 2003
    Location
    BR
    Posts
    6

    Question Wrong 'Order By'

    Does anyone know any bug relationed with memory paging and order by clause?

    I try to explain:

    I have the following code inside a SP:

    create table #tempA (colA char(2), colB numeric(7), colC numeric(3))

    create table #tempB (colA char(2), colB numeric(7), colC numeric(3))
    )
    insert into #tempA
    (...)

    (...)
    insert into #tempB (colA,colB,colC)
    select colA,colB,colC
    from #tempA
    order by
    colB,colA,colC

    select * from #tempB

    While using the reserved memory for the SQL Server, the last 'select' works pretty well. After the memory swapping starts, the 'select' returns data in incorrect order.

    Any Ideas?
    Thank you for all support than you can give me.



  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Without an ORDER BY clause in your SELECT statement, the order is not guaranteed. That is because SELECT * may be done in parallel using multiple threads and result will not be sorted because you did not ask for it.

  3. #3
    Join Date
    May 2003
    Location
    BR
    Posts
    6

    Thumbs up

    Thank you very much! I'd never had been faced with this case before.

    I've corrected the code. It worked very well. Living and learning!

Posting Permissions

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