[dba-SQLServer] Order of data in views

Dan Waters dwaters at usinternet.com
Tue May 13 15:14:21 CDT 2008


I'm not a SQL guy, but wouldn't an unordered view reflect the sort of the
underlying table?

Dan

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Tuesday, May 13, 2008 2:18 PM
To: Dba-Sqlserver
Subject: [dba-SQLServer] Order of data in views

In the past I created a set of count views.  For months I have been 
opening a query window and entering

SELECT * FROM SomeView.

The order of the fields was always ordered, now it is not.

Someone a while back made a comment something like "a view is by its 
nature unsorted".  Why this would be I haven't a clue since there are 
order by criteria right in the view, but be that as it may, this has 
worked in the past and now it is not.

The issue here is that the client expects to see the data sorted.  So 
now I have to go do something like:

SELECT * FROM SomeView Order BY SomeField

And voila, sorted data.  The issue of course is that it is no longer 
simple.  I gave to discover the name of the order by field and enter 
that in my query window.

Any ideas why it did work and now does not?  How to make it just take 
the order of the underlying view and pass it through?

-- 
John W. Colby
www.ColbyConsulting.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list