mssql 2000 按月分区表(来于网络)
来源:互联网 发布:来自新世界类似知乎 编辑:程序博客网 时间:2024/04/28 20:14
--创建
create PROCEDURE SP_Records
@year nvarchar(4)
AS
declare @count int,
@yearmonth nvarchar(6),
@month nvarchar(2)
set @count = 0
while @count <12
begin
set @count = @count + 1
if @count <10 set @month = '0'+convert(nvarchar(1),@count)
else set @month = convert(nvarchar(2),@count)
set @yearmonth = @year+@month
if object_id ('..Records'+@yearmonth+'') is null
exec(
'CREATE TABLE Records'+@yearmonth+'(
-- [ID] [bigint] IDENTITY (1, 1) NOT NULL ,
[ID] [varchar] (50) NOT NULL ,
[Rad_id] [int] NOT NULL ,
[IP] [varchar] (50) NOT NULL ,
[Addtime] [varchar] (20) NOT NULL
CHECK ([Addtime] BETWEEN '''+@year+'-'+@month+'-01 00:00:00'' AND '''+@year+'-'+@month+'-31 23:59:59''),
CONSTRAINT [PK_Records'+@yearmonth+'] PRIMARY KEY
(
[ID],
[Addtime]
) ON [PRIMARY]
) ON [PRIMARY]'
)
end
DECLARE @view varchar(8000)
set @view = ''
select @view = @view + ' UNION ALL SELECT * FROM [dbo].' + name
FROM sysobjects
where name like 'Records[0-9][0-9][0-9][0-9][0-1][0-9]'
and objectproperty(id,'isusertable')=1
set @view = stuff(@view, 1, 11, '')
if object_id('V_Records') is null
set @view = 'CREATE VIEW [V_Records] as ' + @view
else
set @view = 'alter VIEW [V_Records] as ' + @view
exec(@view)
print (@view)
GO
--执行
exec SP_Records @year='2009'
- mssql 2000 按月分区表(来于网络)
- 按月创建分区表
- MSSQL按月季年统计
- mssql 提高性能 - 分区表
- MSSQL Server 创建分区表
- Postgresql 添加分区表(按月和按日通用)
- 建按月日自增分区表
- msSql分区表理解及实现
- 按月分区触发器函数编写,自动创建分区表
- 用到的MSSQL按月按周统计,以后可能用到
- ORACLE用GROUP BY 来分组日期字段 按月分组
- ORACLE用GROUP BY 来分组日期字段 按月分组
- mssql 按月统计,按日统计,按周统计,按季度统计
- 探索MSSQL Server 2000网络连接的安全问题
- 勒索病毒猛于虎 网络空间安全谁来守护?
- 使用dd来备份还原mbr,分区表
- 分区表
- 分区表
- 托盘在XP下不能显示tooltip,在Vista和Windows7下正常
- DSHplus 3.6破解
- 从今天开始,我在CSDN写文章了~~~~
- Oracle外键约束信息的查询
- 用dos窗口调试
- mssql 2000 按月分区表(来于网络)
- HNWE T1 相对定位、绝对定位差别
- phpmailer所有对象和属性 中文
- 半分缘
- 导出CSV EXCEL
- 30岁之前的人生目标是什么
- 有关hibernate的查询
- android widget install and remove
- html2text-mingw