Best way to create indexes in SQL Server

I have four columns in my table (a, b, c, d) that they all depend on the column (date), so in my queries I:

 select a where date 
 select b where date 
 select c where date 
 select d where date

I need to know what is the best way to create indexes for all of them, I have two sentences:

First sentence:

create i_a on a
create i_b on b
create i_c on c
create i_d on d
create i_date on date

Second sentence:

create i_a on a include date
create i_b on b include date
create i_c on c include date
create i_d on d include date

Please which one is better to use.

+4
source share
1 answer

This may help you:

CREATE NONCLUSTERED INDEX Index_Name ON TableName(Date) INCLUDE(A,B,C,D)

The column you want to index should be used for filtering (sentence WHERE). You can add INCLUDEto avoid the search.

+2
source

All Articles