建表:
create table dbo.tt(id int,p float)
declare @i int
set @i=1
while(@i<50000)
begin 
insert dbo.tt values(@i,rand(datepart(ms,getdate())+10000*datepart(s,getdate())))
set @i=@i+1
end
建视图:
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
go
create view dbo.v_tt
with SCHEMABINDING as 
select id,p from dbo.tt
建索引:
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET CONCAT_NULL_YIELDS_NULL ON
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF
create unique clustered index ix_v_tt on dbo.v_tt(id)
执行查询:
select id,p from v_tt where id<23601
用执行计划看了一下,发现还是用table scan,怎么没用上索引呢?