Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 Order By problem in View

Author  Topic 

ClivePot
Starting Member

1 Post

Posted - 2006-04-29 : 17:34:51
I have downloaded and installed SQL Server Express 2003 Adv.. I have created a new database in it and also a table called Customers. In that I have created one field called CustomerName as nvar(255). I have made 10 records by filling in the field with various names. I have then created a new view and asked it to order the records in descending order. When I save and show the view it shows the records still in the order that I inserted them not in descending alphabetical order. If I make it show in ascending order the same problem still occurs. Collation settings are correct for the computer at Latin1. However, I have tried a few others, but none make any difference. SQL Server Express 2003's view will not list my Customers in either ascending or decending alphabetical order. Can anyone give me any suggestions?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-04-29 : 18:41:29
Use an order by clause in your SELECT statement.


CODO ERGO SUM
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-30 : 00:00:57
Records are not stored in any specific order in the database. You have to define the ordering using the ORDER BY when retrieving the records.



KH


Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-04-30 : 06:40:32
I'm not sure when it would be applicable to use in a VIEW, but I believe you can use a SELECT TOP 100 PERCENT in conjunction with an ORDER BY to get define a "pre-sorted View"

Edit: I no longer "believe" it!

Kristen
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2006-04-30 : 07:29:20
quote:
Originally posted by Kristen

I'm not sure when it would be applicable to use in a VIEW, but I believe you can use a SELECT TOP 100 PERCENT in conjunction with an ORDER BY to get define a "pre-sorted View"



Hmm... It might be worth reading this:

http://blogs.msdn.com/queryoptteam/archive/2006/03/24/560396.aspx
Go to Top of Page
   

- Advertisement -