Click here to Skip to main content
15,893,722 members
Home / Discussions / Database
   

Database

 
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 
QuestionAdding values past a field with #VALUE! -- HELP!!! Pin
new_phoenix21-Nov-07 6:20
new_phoenix21-Nov-07 6:20 
QuestionNeed a correction Pin
s3rro21-Nov-07 5:24
s3rro21-Nov-07 5:24 
AnswerRe: Need a correction Pin
Colin Angus Mackay21-Nov-07 5:37
Colin Angus Mackay21-Nov-07 5:37 
GeneralRe: Need a correction Pin
Pete O'Hanlon21-Nov-07 9:58
mvePete O'Hanlon21-Nov-07 9:58 
QuestionStored Procedure Runs Slower than Normal Query Pin
moon_stick21-Nov-07 4:47
moon_stick21-Nov-07 4:47 
AnswerRe: Stored Procedure Runs Slower than Normal Query Pin
Pete O'Hanlon21-Nov-07 5:04
mvePete O'Hanlon21-Nov-07 5:04 
GeneralRe: Stored Procedure Runs Slower than Normal Query Pin
moon_stick21-Nov-07 5:37
moon_stick21-Nov-07 5:37 
GeneralRe: Stored Procedure Runs Slower than Normal Query Pin
Pete O'Hanlon21-Nov-07 10:57
mvePete O'Hanlon21-Nov-07 10:57 
GeneralRe: Stored Procedure Runs Slower than Normal Query Pin
Mark Churchill21-Nov-07 13:23
Mark Churchill21-Nov-07 13:23 

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.