71 lines
2.2 KiB
Transact-SQL
71 lines
2.2 KiB
Transact-SQL
CREATE PROCEDURE [dbo].[Local_CreateLogoutLogTable]
|
|
@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( 'Logout_Log_'+ @year+'_'+@month ) IS NULL
|
|
begin
|
|
declare @br varchar(1500)
|
|
set @br='CREATE TABLE Logout_Log_'+ @year+'_'+@month+
|
|
'(
|
|
[log_id] [bigint] IDENTITY(1,1) NOT NULL,
|
|
[log_type] [smallint] NOT NULL,
|
|
[world_id] [int] NOT NULL,
|
|
[auth_id] [uniqueidentifier] NOT NULL,
|
|
[bcust_id] [nvarchar](50) NOT NULL,
|
|
[character_id] [uniqueidentifier] NOT NULL,
|
|
[character_name] [nvarchar](50) NOT NULL,
|
|
[ChannelID] [smallint] NOT NULL,
|
|
[IP] [char](16) NOT NULL,
|
|
|
|
[date] [datetime] NOT NULL DEFAULT (getdate()),
|
|
inven_gold [int] NOT NULL ,
|
|
storage_gold [int] NOT NULL ,
|
|
character_level [smallint] NOT NULL ,
|
|
character_exp [bigint] NOT NULL ,
|
|
)'
|
|
exec(@br)
|
|
-----
|
|
set @br='ALTER TABLE [dbo].[Logout_Log_'+ @year+'_'+ @month+'] WITH NOCHECK ADD
|
|
CONSTRAINT [PK_log_id_Logout_Log_'+ @year+'_'+ @month+'] PRIMARY KEY CLUSTERED
|
|
(
|
|
[log_id] ASC
|
|
) ON [PRIMARY]'
|
|
exec(@br)
|
|
-----
|
|
set @br='CREATE NONCLUSTERED INDEX [IX_bcust_id_Logout_Log_'+ @year+'_'+ @month+'] ON [dbo].[Logout_Log_'+ @year+'_'+ @month+']
|
|
(
|
|
[bcust_id] ASC
|
|
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]'
|
|
exec(@br)
|
|
-----
|
|
set @br='CREATE NONCLUSTERED INDEX [IX_charid_Logout_Log_'+ @year+'_'+ @month+'] ON [dbo].[Logout_Log_'+ @year+'_'+ @month+']
|
|
(
|
|
[character_id] ASC
|
|
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]'
|
|
exec(@br)
|
|
-----
|
|
set @br='CREATE NONCLUSTERED INDEX [IX_charname_Logout_Log_'+ @year+'_'+ @month+'] ON [dbo].[Logout_Log_'+ @year+'_'+ @month+']
|
|
(
|
|
[character_name] ASC
|
|
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]'
|
|
exec(@br)
|
|
-----
|
|
set @br='CREATE NONCLUSTERED INDEX [IX_logtype_Logout_Log_'+ @year+'_'+ @month+'] ON [dbo].[Logout_Log_'+ @year+'_'+ @month+']
|
|
(
|
|
[log_type] ASC
|
|
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]'
|
|
exec(@br)
|
|
-----
|
|
set @br='CREATE NONCLUSTERED INDEX [IX_date_Logout_Log_'+ @year+'_'+ @month+'] ON [dbo].[Logout_Log_'+ @year+'_'+ @month+']
|
|
(
|
|
[date] ASC
|
|
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]'
|
|
exec(@br)
|
|
end
|