I have a query with an ORDER BY clause. The resultset is about 10000 rows.
Sometimes the ordering of the result is not correct, but when I restart the
sqlserver-process, at least the first time the ordering is correct, but then
after executeing the same query a few times, th ordering gets corrupt!
Has anybody encountered a simmilar Problem?
Does anybody know a workaround?
Thank a lot.
Andy Rohr.What do you mean by not correct? Can you post some code and sample data to
reproduce the problem (including the DDL)?
Do the columns in the ORDER BY list represent a unique key? If not, remember
that ORDER BY can produce different valid orderings if the columns are not
unique. For example, with the following query:
SELECT A, B
FROM Sometable
ORDER BY A
the result:
(1,1)
(1,2)
is just as valid as:
(1,2)
(1,1)
Also, in SQLServer ORDER BY columns reference aliased columns in the SELECT
list but can also reference base table columns which do not appear in the
SELECT list, a feature which can cause some confusion.
--
David Portas
----
Please reply only to the newsgroup
--|||> Please reply only to the newsgroup
I repiled to microsoft.public.sqlserver.programmingsql
No comments:
Post a Comment