?
Solved

Microsoft, SQL Server, 2005, view with order by clause

Posted on 2007-11-18
10
Medium Priority
?
1,453 Views
Last Modified: 2012-06-27
Hi,
I have crated a view with Top 100 Percent in the Select Clause and an order by Column name. It is working fine when I execute the view in the Enterprise Manager.

But When I put,

Select * from View1

It is not giving the sorted result.
0
Comment
Question by:batchakamal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20310889
this works right?
Select * from View1 order by columnname
i think top 100% order by x simply tells it to collect: up to 100%, by order of column x.  it can do that using multiple threads and arrive at some result. but because it's a view, it's the the final result. the result gets dumped in any order (that threads complete)
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20310908
in views, you need to use the following method to allow sortings:


CREATE VIEW view_name 
AS 
SELECT TOP 100 PERCENT ... 
FROM ... 
WHERE ... 
ORDER BY ...

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20310910
sorry, I notice you did that :(

0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20310912
how many CPU does your server have?
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20310971
Check whether there exists another view with the same name and different owner  ?
0
 
LVL 4

Author Comment

by:batchakamal
ID: 20311067
We have Only one processor
0
 
LVL 4

Author Comment

by:batchakamal
ID: 20311073
If I put

Select * From View1 Order By Column2

It is working fine. But I require it to sort when I select.
0
 
LVL 4

Author Comment

by:batchakamal
ID: 20311088
There is only one view with that name.
0
 
LVL 25

Accepted Solution

by:
imitchie earned 1500 total points
ID: 20311109
well in that case,
select top 100000000 *
from table
order by col1
0
 
LVL 4

Author Closing Comment

by:batchakamal
ID: 31409897
It Works out. But I would like to know whether this will affect our performance or not.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question