"Paulo Andre Ortega Ribeiro" <an*******@devdex.com> wrote in message
news:3f*********************@news.frii.net...
I have a Microsoft SQL Server 7.0.
I wrote a sql command that creates a temporary table with a ORDER BY
clause.
When a execute a SELECT on this temporary table sometimes the result is
ok, but sometimes is not ordered. I didnīt see anything like that. Any
clue?
Is there any kind of limits with temporary tables ? Because the command
that creates the temporary table is working and the rsults is always
ordered. But when I create a table with it, sometimes the table is not
ordered.
Paulo
Rows in tables (temporary or permanent) never have an order, even if you
used ORDER BY when you did the INSERT, and even if there's a clustered index
on the table. The only way to be sure you get ordered data is to use ORDER
BY when you SELECT it.
Some tables, especially with clustered indexes, may look like the data is
ordered, but you can't assume it will always work. You could think of it
like this - when you SELECT from the table, you create a result set, and
ORDER BY only works on the result set, not on the table.
Is there some specific reason that you want to order data in the table,
instead of using ORDER BY in your queries? If there is, then maybe you could
give some more details about what you are trying to do, and someone might be
able to suggest a different solution.
Simon