Let the storm money come!

SqlServer 数据归档

Set Statistics io On -- 打开查看IO

-- 1.将数据归档简单操作,按年分,可以分成若干个表
select * into Log2011
from Log
where StartTime between '2011-1-1' and '2011-12-31'

-- 2.为这些表创建一个约束
alter table log2011
add constraint CK_2011 check (StartTime between '2011-1-1' and '2011-12-31')

-- 3.为这些表建立一个视图
--
 这里可以测试,如果用约束和不用约束差别很大
ALTER view V_AllDocLog
as
select * from log2009
union all
select * from Log2010
union all
select * from Log2011
go
posted @ 2011-12-06 22:41  精密~顽石  阅读(950)  评论(0编辑  收藏  举报
在通往地狱的路上,加班能使你更快到达。