Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 10th, 2004, 08:46 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default more than one index on a table

hi all,

I have a table tblCustomers which has about 1000 records. The fields ClientName and Client Points of that table are relevant in this discussion.

I need to list all the clients in alphabetical order in select boxes in more than one page. To make it faster, I have created an index on ClientName. This index is a clustered one. (A stored procedure is used to fetch the list). It is working sufficiently fast.

Then there is a page where I need to list the clients in the descending order of client points. After I created index on ClientName, this listing is fairly slow. I can create another index on ClientPoints (number type). But how can I specify which index to apply in the query in stored procedure ?

I need to apply the first index when I want to fetch Client list in their alphabetical order and the second one when I want to fetch them in the descending order of ClientPoints. May I know how this is possible ?

Thanks

Madhu
 
Old September 10th, 2004, 08:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

If I am right, you should have created a non-clustered index on ClientName, and another on Client Points. IMO, that would have served better.

Hope that helps.
CheerS!

_________________________
- Vijay G
Strive for Perfection
 
Old September 10th, 2004, 09:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Not sure which version you use. You should be able to do that using WITH INDEX
Code:
SELECT sum(col5) as SumVal FROM Table1 WITH (index('IDX_Col1')) WHERE Col1='something'
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 11th, 2004, 05:46 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Hello Vijay,

This is working correctly.

Thanks a lot.





Similar Threads
Thread Thread Starter Forum Replies Last Post
index by table in pl/sql vipin1982 All Other Wrox Books 1 October 1st, 2008 12:19 PM
Retrieve Index Status of a table muralidharan.d SQL Server 2005 1 June 6th, 2008 04:13 PM
'AOIndex' is not an index in this table junedali10 Access 1 April 12th, 2008 05:25 PM
Table Index Problem JDrown Access VBA 1 March 17th, 2006 12:23 PM
Index On Table In VB6 p2pbal SQL Server ASP 1 September 3rd, 2004 05:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.