51 lines
1.5 KiB
Transact-SQL
51 lines
1.5 KiB
Transact-SQL
CREATE PROCEDURE [dbo].[Local_CreateMonitorUserTable]
|
|
@createtime datetime
|
|
as
|
|
set nocount on
|
|
|
|
declare @year varchar(50)
|
|
declare @month varchar(50)
|
|
|
|
set @year = convert(varchar, datepart(yy,@createtime))
|
|
set @month = convert(varchar, datepart(mm,@createtime))
|
|
|
|
if OBJECT_ID( 'MonitorUser_Log_'+ @year+'_'+@month ) IS NULL
|
|
begin
|
|
declare @br varchar(1500)
|
|
set @br='CREATE TABLE MonitorUser_Log_'+ @year+'_'+@month+
|
|
'(
|
|
|
|
|
|
[log_id] [int] IDENTITY(1,1) NOT NULL,
|
|
[log_type] [int] NOT NULL,
|
|
[world_id] [int] NOT NULL,
|
|
[CU_gate] [int] NOT NULL,
|
|
[CU_lobby] [int] NOT NULL,
|
|
[CU_PVP] [int] NOT NULL,
|
|
[CU_dungeon] [int] NOT NULL,
|
|
[CU_total] [int] NOT NULL,
|
|
[date] [datetime] NOT NULL CONSTRAINT [DF_MonitorUser_Log_'+ @year+'_'+ @month+'_entry_date] DEFAULT (getdate()),
|
|
)'
|
|
|
|
exec(@br)
|
|
-----
|
|
set @br='ALTER TABLE [dbo].[MonitorUser_Log_'+ @year+'_'+ @month+'] WITH NOCHECK ADD
|
|
CONSTRAINT [PK_log_id_MonitorUser_Log_'+ @year+'_'+ @month+'] PRIMARY KEY CLUSTERED
|
|
(
|
|
[log_id] ASC
|
|
) ON [PRIMARY]'
|
|
exec(@br)
|
|
-----
|
|
set @br='CREATE NONCLUSTERED INDEX [IX_log_type_MonitorUser_Log_'+ @year+'_'+ @month+'] ON [dbo].[MonitorUser_Log_'+ @year+'_'+ @month+']
|
|
(
|
|
[log_type] ASC
|
|
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]'
|
|
exec(@br)
|
|
-----
|
|
set @br='CREATE NONCLUSTERED INDEX [IX_world_id_MonitorUser_Log_'+ @year+'_'+ @month+'] ON [dbo].[MonitorUser_Log_'+ @year+'_'+ @month+']
|
|
(
|
|
[world_id] ASC
|
|
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]'
|
|
exec(@br)
|
|
|
|
end
|