CREATE PROCEDURE [dbo].[Local_CreateMonitorNoticeTable] @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( 'MonitorNotice_Log_'+ @year+'_'+@month ) IS NULL begin declare @br varchar(1500) set @br='CREATE TABLE MonitorNotice_Log_'+ @year+'_'+@month+ '( [log_id] [int] IDENTITY(1,1) NOT NULL, [log_type] [int] NOT NULL, [world_id] [int] NOT NULL, [target] [tinyint] NOT NULL, [notice_type] [tinyint] NOT NULL, [notice_cycle] [tinyint] NOT NULL, [notice] [nvarchar] (255) NOT NULL, [gm_ID] [nvarchar] (16) NOT NULL, [date] [datetime] NOT NULL CONSTRAINT [DF_MonitorNotice_Log_'+ @year+'_'+ @month+'_entry_date] DEFAULT (getdate()), )' exec(@br) ----- set @br='ALTER TABLE [dbo].[MonitorNotice_Log_'+ @year+'_'+ @month+'] WITH NOCHECK ADD CONSTRAINT [PK_log_id_MonitorNotice_Log_'+ @year+'_'+ @month+'] PRIMARY KEY CLUSTERED ( [log_id] ASC ) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_log_type_MonitorNotice_Log_'+ @year+'_'+ @month+'] ON [dbo].[MonitorNotice_Log_'+ @year+'_'+ @month+'] ( [log_type] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_world_id_MonitorNotice_Log_'+ @year+'_'+ @month+'] ON [dbo].[MonitorNotice_Log_'+ @year+'_'+ @month+'] ( [world_id] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) ----- set @br='CREATE NONCLUSTERED INDEX [IX_gm_ID_MonitorNotice_Log_'+ @year+'_'+ @month+'] ON [dbo].[MonitorNotice_Log_'+ @year+'_'+ @month+'] ( [gm_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) set @br='CREATE NONCLUSTERED INDEX [IX_date_MonitorNotice_Log_'+ @year+'_'+ @month+'] ON [dbo].[MonitorNotice_Log_'+ @year+'_'+ @month+'] ( [date] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]' exec(@br) end