CREATE PROCEDURE [dbo].[Local_CreateDungeonClearTable] @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( 'DungeonClear_Log_'+ @year+'_'+@month ) IS NULL begin declare @br varchar(2000) set @br='CREATE TABLE DungeonClear_Log_'+ @year+'_'+@month+ '( [log_id] [int] IDENTITY(1,1) NOT NULL, [date] [datetime] NOT NULL CONSTRAINT [DF_DungeonClear_Log_'+ @year+'_'+ @month+'_entry_date] DEFAULT (getdate()), [log_type] [int] NOT NULL, [instance_id] [uniqueidentifier] NOT NULL, [bcust_id] [varchar](24) COLLATE Korean_Wansung_CI_AS NOT NULL, [character_id] [uniqueidentifier] NOT NULL, [character_name] [nvarchar](16) COLLATE Korean_Wansung_CI_AS NOT NULL, [character_class] [int] NOT NULL, [character_level] [int] NOT NULL, [membercountclear] [tinyint] NOT NULL, [clearrank] [nvarchar](4) COLLATE Korean_Wansung_CI_AS NOT NULL, [stylishpoint] [smallint] NOT NULL, [hitcount] [smallint] NOT NULL, [chain] [smallint] NOT NULL, [killcount] [smallint] NOT NULL, [cleartime] [int] NOT NULL, [cardid] [int] NOT NULL, [cardrewardid] [int] NOT NULL, [cardrewardcount] [int] NOT NULL, [addexp] [int] NOT NULL, [death] [tinyint] NOT NULL, [rebirth] [smallint] NOT NULL, [replay] [tinyint] NOT NULL, [dungeonid] [int] NOT NULL, [difficulty] [int] NOT NULL, [playpoint] [int] NOT NULL, )' exec(@br) ----- set @br='ALTER TABLE [dbo].[DungeonClear_Log_'+ @year+'_'+ @month+'] WITH NOCHECK ADD CONSTRAINT [PK_log_id_DungeonClear_Log_'+ @year+'_'+ @month+'] PRIMARY KEY CLUSTERED ( [log_id] ASC ) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_character_class_DungeonClear_Log_'+ @year+'_'+ @month+'] ON [dbo].[DungeonClear_Log_'+ @year+'_'+ @month+'] ( [character_class] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_entry_date_DungeonClear_Log_'+ @year+'_'+ @month+'] ON [dbo].[DungeonClear_Log_'+ @year+'_'+ @month+'] ( [date] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_logtype_tem_Log_'+ @year+'_'+ @month+'] ON [dbo].[DungeonClear_Log_'+ @year+'_'+ @month+'] ( [log_type] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) end