/****************************************************
AboutSQLServer.com blog
Written by Dmitri Korotkevitch

INDEX SEEK, INDEX SCAN, SEEKABLE PREDICATES 
2010-10-13
*****************************************************/

set nocount on

create table dbo.Orders
(
	OrderId int not null,
	ADate date not null,
	Amount smallmoney not null,
	
	constraint PK_Orders
	primary key clustered(OrderId)
)
go

insert into dbo.Orders(OrderId, ADate, Amount)
	select 1, '2010-10-01', 10 union all
	select 2, '2010-10-02', 40 union all
	select 3, '2010-10-01', 15 union all
	select 4, '2010-10-05', 5 union all
	select 5, '2010-10-06', 11 union all
	-- more rows
	select 99, '2010-10-01', 43 union all
	select 100, '2010-10-03', 40
go

select * from dbo.Orders where ADate = '2010-10-01'
go

create index IDX_Orders_ADate
on dbo.Orders(ADate)
go

select OrderId, ADate from dbo.Orders 
where ADate = '2010-10-01'
go
