CREATE PROCEDURE [dbo].[Local_CreatePvpResultTable] @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( 'Pvp_Result_Log_'+ @year+'_'+@month ) IS NULL begin declare @br varchar(1500) set @br='CREATE TABLE Pvp_Result_Log_'+ @year+'_'+@month+ '( [log_id] [bigint] IDENTITY(1,1) NOT NULL, [log_type] [smallint] NOT NULL, [auth_id] [uniqueidentifier] NOT NULL, [bcust_id] [nvarchar] (24) NOT NULL, [character_id] [uniqueidentifier] NOT NULL, [character_name] [nvarchar] (16) NOT NULL, [character_class] [int] NOT NULL, [character_level] [int] NOT NULL, [channel_type] [int] NOT NULL, [room_id] [uniqueidentifier] NOT NULL, [room_world] [int] NOT NULL, [room_type] [int] NOT NULL, [PZoneID] [int] NOT NULL, [pvp_team] [smallint] NOT NULL, [pvp_score] [int] NOT NULL, [pvp_point] [int] NOT NULL, [pvp_grade] [int] NOT NULL, [pvp_totalscore] [int] NOT NULL, [pvp_totalpoint] [int] NOT NULL, [pvp_rank] [int] NOT NULL, [pvp_kill] [int] NOT NULL, [pvp_die] [int] NOT NULL, [pvp_damage] [int] NOT NULL, [pvp_cleartime] [int] NOT NULL, [date] [datetime] NOT NULL CONSTRAINT [DF_Pvp_Result_Log_'+ @year+'_'+ @month+'_entry_date] DEFAULT (getdate()), )' exec(@br) ----- set @br='ALTER TABLE [dbo].[Pvp_Result_Log_'+ @year+'_'+ @month+'] WITH NOCHECK ADD CONSTRAINT [PK_log_id_Pvp_Result_Log_'+ @year+'_'+ @month+'] PRIMARY KEY CLUSTERED ( [log_id] ASC ) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_log_type_Pvp_Result_Log_'+ @year+'_'+ @month+'] ON [dbo].[Pvp_Result_Log_'+ @year+'_'+ @month+'] ( [log_type] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_bcust_id_Pvp_Result_Log_'+ @year+'_'+ @month+'] ON [dbo].[Pvp_Result_Log_'+ @year+'_'+ @month+'] ( [bcust_id] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_character_name_Pvp_Result_Log_'+ @year+'_'+ @month+'] ON [dbo].[Pvp_Result_Log_'+ @year+'_'+ @month+'] ( [character_name] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_room_world_Pvp_Result_Log_'+ @year+'_'+ @month+'] ON [dbo].[Pvp_Result_Log_'+ @year+'_'+ @month+'] ( [room_world] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_date_Pvp_Result_Log_'+ @year+'_'+ @month+'] ON [dbo].[Pvp_Result_Log_'+ @year+'_'+ @month+'] ( [date] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) end