Click here to Skip to main content
15,901,284 members
Home / Discussions / Database
   

Database

 
AnswerRe: dividing Pin
andyharman22-Nov-07 1:53
professionalandyharman22-Nov-07 1:53 
Questionhow to make many foreign key from one table [modified] Pin
Xmen Real 22-Nov-07 0:50
professional Xmen Real 22-Nov-07 0:50 
QuestionRegarding select Date Pin
Aavesh Agarwal21-Nov-07 22:33
Aavesh Agarwal21-Nov-07 22:33 
AnswerRe: Regarding select Date Pin
joemonvarghese21-Nov-07 23:58
joemonvarghese21-Nov-07 23:58 
QuestionHow to run Dynamic SQL Query Securely? Pin
DotNetWWW21-Nov-07 22:31
DotNetWWW21-Nov-07 22:31 
AnswerRe: How to run Dynamic SQL Query Securely? Pin
Colin Angus Mackay21-Nov-07 22:46
Colin Angus Mackay21-Nov-07 22:46 
QuestionBulk Export Task Pin
RAGHAVENDRAN200721-Nov-07 20:22
RAGHAVENDRAN200721-Nov-07 20:22 
Questionplzz help me... Pin
potlakayala21-Nov-07 20:12
potlakayala21-Nov-07 20:12 
AnswerRe: plzz help me... Pin
Colin Angus Mackay21-Nov-07 21:35
Colin Angus Mackay21-Nov-07 21:35 
Questionerror Pin
mahenputta21-Nov-07 19:09
mahenputta21-Nov-07 19:09 
AnswerRe: error Pin
Joe21-Nov-07 19:12
Joe21-Nov-07 19:12 
GeneralRe: error Pin
mahenputta21-Nov-07 19:24
mahenputta21-Nov-07 19:24 
Questionhow to display table column data are starting letter in capital letter Pin
Murugan.nett21-Nov-07 8:28
Murugan.nett21-Nov-07 8:28 
Answercross post Pin
pmarfleet21-Nov-07 8:42
pmarfleet21-Nov-07 8:42 
GeneralRe: cross post Pin
Paul Conrad23-Nov-07 8:33
professionalPaul Conrad23-Nov-07 8:33 
QuestionSql Server 2005 indexing Pin
Chazzysb21-Nov-07 7:21
Chazzysb21-Nov-07 7:21 
AnswerRe: Sql Server 2005 indexing Pin
Hesham Amin21-Nov-07 10:58
Hesham Amin21-Nov-07 10:58 
The best way to know is to try it, make the tables, fill them with data, execute queries showing the execution plan. In the execution plan, SQL Server will tell you what indexes were used.

In general, If you have composite keys,indexes the 1st column in the index must be referenced in the query (specifically in the where or join) for sql server to consider using this index.

about you samples:
based on the above mentioned information and some experience I have with this, these can be the expected behavior of SQL Server:

where field1 = a (Index Will be used)
where field3 = a (Index Will not be used)
where field1 = a and field2 = b (Index Will be used)
where field2 = a and field3 = b (Index Will not be used)
where field1 = a and field3 = b (Index Will be used)
where field1 = a and field4 = b (Index Will be used)
where field4 = a and field1 = b (Index Will be used, sql server is smart enough Smile | :) )

After adding index on Field4:
where field1 = a and field4 = b (one of the two indexes will be used, not both)
where field4 = a and field1 = b (one of the two indexes will be used, not both)
where field3 = a and field4 = b (index on field4 will be used)

note that whether SQL Server will use the index or not depends on many factors, for example statistics and granularity on index data.



Hesham A. Amin
My blog

QuestionReader problem Pin
kjosh21-Nov-07 6:50
kjosh21-Nov-07 6:50 
AnswerRe: Reader problem Pin
Frank Kerrigan21-Nov-07 10:05
Frank Kerrigan21-Nov-07 10:05 
AnswerRe: Reader problem Pin
Prateek G21-Nov-07 20:24
Prateek G21-Nov-07 20:24 
GeneralRe: Reader problem Pin
Colin Angus Mackay21-Nov-07 22:35
Colin Angus Mackay21-Nov-07 22:35 
GeneralRe: Reader problem Pin
Prateek G21-Nov-07 22:44
Prateek G21-Nov-07 22:44 
GeneralRe: Reader problem Pin
Colin Angus Mackay21-Nov-07 22:50
Colin Angus Mackay21-Nov-07 22:50 
AnswerRe: Reader problem Pin
Colin Angus Mackay21-Nov-07 22:37
Colin Angus Mackay21-Nov-07 22:37 
AnswerRe: Reader problem Pin
Prateek G21-Nov-07 22:56
Prateek G21-Nov-07 22:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.