Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I'm selecting data from table depends upon value of one or two columns.

eg. select Column_A,Column_B from tbl_name where Column_C=@value

plz help me to apply non clustered index on this
Posted

1 solution

Check bellow link for help

Clustered and Non-Clustered Index in SQL 2005[^]
 
Share this answer
 
Comments
Dipali_Wagh 5-Jul-13 7:16am    
but tell me if select query depends upon two columns then what to do?
can u give me example?
Mukesh Ghosh 5-Jul-13 7:23am    
CREATE TABLE dbo.foo1(A INT, B INT, C INT);
CREATE NONCLUSTERED INDEX foo1x ON dbo.foo1(B, C) INCLUDE(A);
SELECT A
FROM (
SELECT A, ROW_NUMBER() OVER (PARTITION BY B ORDER BY C DESC) RN
FROM dbo.foo1
) q
WHERE rn = 1;
Dipali_Wagh 6-Jul-13 1:44am    
thanks, its working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900