create table t(a int, b varchar(20), c int)
declare @i int
select @i = 1
while @i <10000
begin
insert t select @i,'a' + convert(varchar(7),@i), @i + 100
select @i = @i + 1
end
select * from t
create clustered index ix_t_a on t(a)
create index ix_t_b on t(c)
dbcc show_statistics(t,'ix_t_a')
select * from sys.stats where object_id = object_id('t')
select * from t where c = 111
update statistics t with column
select name, auto_created, stats_date(object_id, stats_id) as update_date from sys.stats
where object_id = object_id('t')
name auto_created update_date
ix_t_a 0 2010-08-05 18:53:52.730
ix_t_b 0 2010-08-05 18:54:03.690
name auto_created update_date
_WA_Sys_00000002_09CAFFB2 1 2010-08-05 18:55:01.667
select * from t where b = 'a245'
alter index all on t rebuild
drop table t
Wednesday, August 18, 2010
Subscribe to:
Posts (Atom)