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
 General SQL Server Forums
 New to SQL Server Programming
 How to use different Indexes in View

Author  Topic 

bharatagraj
Starting Member

6 Posts

Posted - 2005-08-18 : 16:24:22
I have a "employee" table. This table has a primary key "emp_id" this by default becomes the cluster index of the table.

There is a view "empl" defined with the index on "emp_id" field as "Emp_ID". This becomes the cluster index for the view. There are other two non clustered indexes "Fname" and "Lname".

I want to use Both indexes without using "Order By" Clause. Can I get the order of the "Fname" or "Lname" without using "Order By" Clause? How?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-08-18 : 16:25:55
Why don't you want to use an ORDER BY?

Tara
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-19 : 03:23:18
"Why don't you want to use an ORDER BY"

Perhaps the idea is that SELECT * FROM VIEW has a defined sequence [without the user having to have an ORDER BY?]

If that's the case I think you can do:

CREATE VIEW MyView
AS
SELECT *
FROM
(
SELECT TOP 100 PERCENT *
FROM MyTable
ORDER BY Fname
) X

Kristen
Go to Top of Page

bharatagraj
Starting Member

6 Posts

Posted - 2005-08-19 : 12:48:15
quote:
Originally posted by tduggan

Why don't you want to use an ORDER BY?

Tara
I am new to this environment and want to know if more alternatives exisist.

Go to Top of Page
   

- Advertisement -