-- =============================================
-- Author: MUEMU.tech
-- DB: Battlecore
-- Version: 12.0.0.0
-- =============================================

USE [BattleCore]
GO


/****** Object:  Table [dbo].[MultiWarehouse]    Script Date: 10/07/2019 18:01:00 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MultiWarehouse]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[MultiWarehouse]
GO

CREATE TABLE [dbo].[MultiWarehouse] (
        [AccountID] [varchar] (10) NOT NULL ,
	[Items] [varbinary] (7680) NULL ,
	[Money] [int] NOT NULL ,
        [Number] [int] NOT NULL
) ON [PRIMARY]
GO


IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WarehouseChange]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WarehouseChange]
GO

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[WarehouseChange] @Number1 int,@Account varchar(10) as

BEGIN

SET NOCOUNT ON

DECLARE @Number2 int
DECLARE @Items1 varbinary(7680)
DECLARE @Items2 varbinary(7680)
DECLARE @Money1 int
DECLARE @Money2 int 
DECLARE @return int

SET	XACT_ABORT ON

SET @return = 0

BEGIN TRANSACTION

SELECT @Items1=Items,@Money1=Money,@Number2=Number FROM warehouse WHERE AccountID=@Account

if(@@ROWCOUNT < 1)
BEGIN
    SET @return = 1
    GOTO CheckTran
END
	
    if not @Number2=@Number1
    BEGIN     

        if not EXISTS (SELECT AccountID FROM MultiWarehouse WHERE AccountID=@Account AND Number=@Number1)
        BEGIN

	    INSERT INTO MultiWarehouse (AccountID,Items,Money,Number) VALUES (@Account,cast(REPLICATE(char(0xff),7680) as varbinary(7680)),0,@Number1)

        if(@@error <> 0)
	    BEGIN
            SET @return = 1
            GOTO CheckTran
	    END

        END

        if not EXISTS (SELECT AccountID FROM MultiWarehouse WHERE AccountID=@Account AND Number=@Number2) begin

	    INSERT INTO MultiWarehouse (AccountID,Items,Money,Number) VALUES (@Account,cast(REPLICATE(char(0xff),7680) as varbinary(7680)),0,@Number2)

        if(@@error <> 0)
	    BEGIN
            SET @return = 1
            GOTO CheckTran
	    END

        end

        UPDATE MultiWarehouse SET Items=@Items1,Money=@Money1,Number=@Number2 WHERE AccountID=@Account AND Number=@Number2

        if(@@error <> 0)
	    BEGIN
            SET @return = 1
            GOTO CheckTran
	    END
 
        SELECT @Items2=Items,@Money2=Money FROM MultiWarehouse WHERE AccountID=@Account AND Number=@Number1

        if(@@error <> 0)
	    BEGIN
            SET @return = 1
            GOTO CheckTran
	    END

        UPDATE warehouse SET Items=@Items2,Money=@Money2,Number=@Number1 WHERE AccountID=@Account

        if(@@error <> 0)
	    BEGIN
            SET @return = 1
            GOTO CheckTran
	    END

    END

CheckTran:
if(@return <> 0)
BEGIN
    ROLLBACK TRANSACTION
END

else

BEGIN
    COMMIT TRANSACTION
END

SELECT @return

SET	XACT_ABORT OFF
set nocount off
END

/****** Object:  Table [dbo].[SNSData]    Script Date: 10/07/2019 18:01:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SNSData](
	[Name] [varchar](10) NOT NULL,
	[Data] [binary](255) NULL,
 CONSTRAINT [PK_SNSData] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO


/****** Object:  Table [dbo].[HelperData]    Script Date: 06/10/2018 12:52:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[HelperData](
	[Name] [varchar](10) NOT NULL,
	[Data] [binary](512) NULL,
 CONSTRAINT [PK_HelperData] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO


/****** Object:  Table [dbo].[T_EventMapEnterLimit]    Script Date: 03/03/2019 00:33:26 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[T_EventMapEnterLimit](
	[CharacterName] [varchar](10) NOT NULL,
	[BloodCastle] [tinyint] NOT NULL,
	[ChaosCastle] [tinyint] NOT NULL,
	[DevilSquare] [tinyint] NOT NULL,
	[DoppelGanger] [tinyint] NOT NULL,
	[ImperialGuardian] [tinyint] NOT NULL,
	[IllusionTempleRenewal] [tinyint] NOT NULL,
	[LastDate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_T_EventMapEnterLimit] PRIMARY KEY CLUSTERED 
(
	[CharacterName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


/****** Object:  Table [dbo].[IGC_ARCA_BATTLE_WIN_GUILD_INFO]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IGC_ARCA_BATTLE_WIN_GUILD_INFO](
	[G_Name] [varchar](8) NOT NULL,
	[G_Number] [int] NOT NULL,
	[WinDate] [smalldatetime] NOT NULL,
	[OuccupyObelisk] [tinyint] NOT NULL,
	[ObeliskGroup] [tinyint] NOT NULL,
	[LeftTime] [bigint] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IGC_ARCA_BATTLE_PROC_STATE]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[IGC_ARCA_BATTLE_PROC_STATE](
	[Proc_State] [tinyint] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[GameServerInfo]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GameServerInfo](
	[Number] [int] NOT NULL,
	[ItemCount] [bigint] NULL,
	[ZenCount] [int] NULL,
	[GmItemCount] [int] NULL,
	[AceItemCount] [int] NULL,
	[GensRankingMonth] [int] NULL,
	[PartyCount] [int] NOT NULL default 0,
 CONSTRAINT [PK_GameServerInfo] PRIMARY KEY NONCLUSTERED 
(
	[Number] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[DefaultClassType]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[DefaultClassType](
	[Class] [tinyint] NOT NULL,
	[Strength] [smallint] NULL,
	[Dexterity] [smallint] NULL,
	[Vitality] [smallint] NULL,
	[Energy] [smallint] NULL,
	[MagicList] [varbinary](450) NULL,
	[Life] [real] NULL,
	[MaxLife] [real] NULL,
	[Mana] [real] NULL,
	[MaxMana] [real] NULL,
	[MapNumber] [smallint] NULL,
	[MapPosX] [smallint] NULL,
	[MapPosY] [smallint] NULL,
	[Quest] [varbinary](100) NULL,
	[DbVersion] [tinyint] NULL,
	[Leadership] [smallint] NULL,
	[Level] [smallint] NULL,
	[LevelUpPoint] [smallint] NULL,
	[Inventory] [varbinary](7584) NULL,
	[LevelLife] [real] NULL,
	[LevelMana] [real] NULL,
	[VitalityToLife] [real] NULL,
	[EnergyToMana] [real] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CustomQuest]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[CustomQuest](
	[Name] [varchar](10) NOT NULL,
	[Quest] [int] NOT NULL,
 CONSTRAINT [PK_CustomQuest1] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Character]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Character](
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[cLevel] [int] NULL,
	[LevelUpPoint] [int] NULL,
	[Class] [tinyint] NULL,
	[Experience] [bigint] NULL,
	[Strength] [int] NULL,
	[Dexterity] [int] NULL,
	[Vitality] [int] NULL,
	[Energy] [int] NULL,
	[MagicList] [varbinary](450) NULL,
	[Money] [int] NULL,
	[Life] [real] NULL,
	[MaxLife] [real] NULL,
	[Mana] [real] NULL,
	[MaxMana] [real] NULL,
	[MapNumber] [smallint] NULL,
	[MapPosX] [smallint] NULL,
	[MapPosY] [smallint] NULL,
	[MapDir] [tinyint] NULL,
	[PkCount] [int] NULL,
	[PkLevel] [int] NULL,
	[PkTime] [int] NULL,
	[MDate] [smalldatetime] NULL,
	[LDate] [smalldatetime] NULL,
	[CtlCode] [tinyint] NULL,
	[Quest] [varbinary](100) NULL,
	[Leadership] [int] NULL,
	[ChatLimitTime] [smallint] NOT NULL,
	[RESETS] [int] NOT NULL,
	[Inventory] [varbinary](7584) NULL,
	[Married] [int] NULL,
	[MarryName] [varchar](10) NULL,
	[mLevel] [int] NOT NULL,
	[mlPoint] [int] NOT NULL,
	[mlExperience] [bigint] NOT NULL,
	[mlNextExp] [bigint] NOT NULL,
	[InventoryExpansion] [tinyint] NOT NULL,
	[WinDuels] [int] NOT NULL,
	[LoseDuels] [int] NOT NULL,
	[PenaltyMask] [int] NOT NULL,
	[BlockChatTime] [bigint] NULL,
	[FruitAddPoint] [int] NOT NULL,
	[FruitSubPoint] [int] NOT NULL,
	[GRANDRESET] [int] NOT NULL,
	[GRBonusSTR] [int] NOT NULL,
	[GRBonusAGI] [int] NOT NULL,
	[GRBonusVIT] [int] NOT NULL,
	[GRBonusENE] [int] NOT NULL,
	[GRBonusCMD] [int] NOT NULL,
	[CustomQuestOn] [int] NOT NULL,
	[GiftItem] [int] NOT NULL,
	[HuntingUserOpen] [int] NOT NULL,
	[AutoReset] [int] NOT NULL,
	[QuestIndex] [int] NOT NULL,
	[QuestState] [int] NOT NULL,
	[QuestVar] [int] NOT NULL,
	[QuestStat] [int] NOT NULL,
 CONSTRAINT [PK_Character] PRIMARY KEY NONCLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[C_PlayerKiller_Info]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[C_PlayerKiller_Info](
	[Victim] [varchar](20) NOT NULL,
	[Killer] [varchar](20) NOT NULL,
	[KillDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BattleCoreInfo]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BattleCoreInfo](
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[UBFName] [varchar](10) NOT NULL,
	[ServerCode] [int] NOT NULL,
	[RegisterState] [int] NOT NULL,
	[RegisterMonth] [int] NOT NULL,
	[RegisterDay] [int] NOT NULL,
	[LeftTime] [smalldatetime] NULL,
	[Observer] [int] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BattleCore_PetItem_Info]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BattleCore_PetItem_Info](
	[ItemSerial] [bigint] NOT NULL,
	[ServerCode] [int] NOT NULL,
	[Pet_Level] [smallint] NULL,
	[Pet_Exp] [bigint] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[BattleCore_DevilSquareFinal_Reward]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BattleCore_DevilSquareFinal_Reward](
	[RewardGuid] [int] IDENTITY(1,1) NOT NULL,
	[CharName] [varchar](10) NOT NULL,
	[Stage] [tinyint] NOT NULL,
	[RewardType] [tinyint] NOT NULL,
	[RewardGain] [tinyint] NOT NULL,
	[RewardDate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_BattleCore_DevilSquareFinal_Reward] PRIMARY KEY CLUSTERED 
(
	[RewardGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BattleCore_ChaosCastleFinal_Reward]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BattleCore_ChaosCastleFinal_Reward](
	[RewardGuid] [int] IDENTITY(1,1) NOT NULL,
	[CharName] [varchar](10) NOT NULL,
	[Stage] [tinyint] NOT NULL,
	[RewardType] [tinyint] NOT NULL,
	[RewardGain] [tinyint] NOT NULL,
	[RewardDate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_BattleCore_ChaosCastleFinal_Reward] PRIMARY KEY CLUSTERED 
(
	[RewardGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BattleCore_ChaosCastle_Reward]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BattleCore_ChaosCastle_Reward](
	[RewardGuid] [int] IDENTITY(1,1) NOT NULL,
	[CharName] [varchar](10) NOT NULL,
	[RewardType] [tinyint] NOT NULL,
	[RewardGain] [tinyint] NOT NULL,
	[RewardDate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_BattleCore_ChaosCastle_Reward] PRIMARY KEY CLUSTERED 
(
	[RewardGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BattleCore_ChaosCastle_KillPoint]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BattleCore_ChaosCastle_KillPoint](
	[Name] [varchar](10) NOT NULL,
	[KillPoint] [int] NOT NULL,
	[CastleIndex] [int] NOT NULL,
 CONSTRAINT [PK_BattleCore_ChaosCastle_KillPoint] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[AccountCharacter]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[AccountCharacter](
	[Number] [int] IDENTITY(1,1) NOT NULL,
	[Id] [varchar](10) NOT NULL,
	[GameID1] [varchar](10) NULL,
	[GameID2] [varchar](10) NULL,
	[GameID3] [varchar](10) NULL,
	[GameID4] [varchar](10) NULL,
	[GameID5] [varchar](10) NULL,
	[GameIDC] [varchar](10) NULL,
	[MoveCnt] [tinyint] NULL,
	[WarehouseExpansion] [tinyint] NOT NULL,
	[SecCode] [int] NOT NULL,
	[ExtClass] [int] NOT NULL,
 CONSTRAINT [PK_AccountCharacter] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IGC_ChaosCastleFinal_Ranking]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IGC_ChaosCastleFinal_Ranking](
	[mRank] [int] NOT NULL,
	[mName] [varchar](10) NOT NULL,
	[mCCFType] [tinyint] NOT NULL,
	[mClass] [int] NOT NULL,
	[mPoint] [int] NOT NULL,
	[mDate] [smalldatetime] NOT NULL,
 CONSTRAINT [NC_PK_IGC_ChaosCastleFinal_Ranking] PRIMARY KEY NONCLUSTERED 
(
	[mName] ASC,
	[mCCFType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IGC_ChaosCastleFinal_Scores]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IGC_ChaosCastleFinal_Scores](
	[mName] [varchar](10) NOT NULL,
	[mCCFType] [tinyint] NOT NULL,
	[mPoint] [int] NOT NULL,
	[mDate] [smalldatetime] NOT NULL,
	[mCharLevel] [smallint] NULL,
	[mCharExperience] [bigint] NULL,
	[mCharClass] [smallint] NULL,
 CONSTRAINT [CL_PK_IGC_ChaosCastleFinal_Scores] PRIMARY KEY CLUSTERED 
(
	[mName] ASC,
	[mCCFType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IGC_DevilSquareFinal_Ranking]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IGC_DevilSquareFinal_Ranking](
	[mRank] [int] NOT NULL,
	[mUserName1] [varchar](10) NOT NULL,
	[mUserName2] [varchar](10) NOT NULL,
	[mServerCode1] [int] NOT NULL,
	[mServerCode2] [int] NOT NULL,
	[mDSFType] [int] NOT NULL,
	[mPoint] [int] NOT NULL,
	[mEnterCount] [int] NOT NULL,
	[mDate] [smalldatetime] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IGC_DevilSquareFinal_Rewards]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IGC_DevilSquareFinal_Rewards](
	[mAccountID] [varchar](10) NOT NULL,
	[mName] [varchar](10) NOT NULL,
	[mClass] [int] NOT NULL,
	[mDSFType] [tinyint] NOT NULL,
	[mRewardYear] [int] NOT NULL,
	[mRewardMonth] [int] NOT NULL,
	[mRewardStartDay] [int] NOT NULL,
	[mRewardEndDay] [int] NOT NULL,
	[mRewardGain] [tinyint] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IGC_DevilSquareFinal_Scores]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IGC_DevilSquareFinal_Scores](
	[mAccountID1] [varchar](10) NOT NULL,
	[mName1] [varchar](10) NOT NULL,
	[mUserLevel1] [varchar](10) NOT NULL,
	[mAccountID2] [varchar](10) NOT NULL,
	[mName2] [varchar](10) NOT NULL,
	[mUserLevel2] [varchar](10) NOT NULL,
	[mDSFType] [tinyint] NOT NULL,
	[mPoint] [int] NOT NULL,
	[mEnterCount] [int] NOT NULL,
	[mDate] [smalldatetime] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IGC_PeriodBuffInfo]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IGC_PeriodBuffInfo](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[CharacterName] [varchar](10) NOT NULL,
	[BuffIndex] [smallint] NOT NULL,
	[EffectType1] [smallint] NOT NULL,
	[EffectType2] [smallint] NULL,
	[ExpireDate] [bigint] NOT NULL,
	[Duration] [int] NOT NULL,
 CONSTRAINT [PK_IGC_PeriodBuffInfo] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[QUEST_PLAYER_INFO]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[QUEST_PLAYER_INFO](
	[CHAR_NAME] [varchar](10) NOT NULL,
	[QuestID] [smallint] NULL,
	[MonsterID1] [smallint] NULL,
	[MonsterKillCount1] [smallint] NULL,
	[MonsterID2] [smallint] NULL,
	[MonsterKillCount2] [smallint] NULL,
	[MonsterID3] [smallint] NULL,
	[MonsterKillCount3] [smallint] NULL,
	[MonsterID4] [smallint] NULL,
	[MonsterKillCount4] [smallint] NULL,
	[MonsterID5] [smallint] NULL,
	[MonsterKillCount5] [smallint] NULL,
 CONSTRAINT [PK_QUEST_PLAYER_INFO1] PRIMARY KEY CLUSTERED 
(
	[CHAR_NAME] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PetWarehouse]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PetWarehouse](
	[AccountID] [varchar](12) NOT NULL,
	[Name] [varchar](12) NOT NULL,
	[Items] [varbinary](3264) NULL,
	[DbVersion] [tinyint] NULL,
	[SubEquip] [tinyint] NULL,
 CONSTRAINT [PK_PetWarehouser] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[OptionData]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[OptionData](
	[Name] [varchar](10) NOT NULL,
	[SkillKey] [binary](20) NULL,
	[GameOption] [tinyint] NULL,
	[Qkey] [tinyint] NULL,
	[Wkey] [tinyint] NULL,
	[Ekey] [tinyint] NULL,
	[ChatWindow] [tinyint] NULL,
	[Rkey] [tinyint] NULL,
	[QWERLevel] [int] NULL,
	[EnableChangeMode] [tinyint] NULL,
	[PlayGuideLvL] [int] NOT NULL,
	[PlayGuideCheck] [int] NOT NULL,
 CONSTRAINT [PK_OptionData] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_PetItem_Info]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T_PetItem_Info](
	[ItemSerial] [bigint] NOT NULL,
	[Pet_Level] [smallint] NULL,
	[Pet_Exp] [bigint] NULL,
 CONSTRAINT [PK_T_Pet_Info] PRIMARY KEY CLUSTERED 
(
	[ItemSerial] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[T_PentagramInfo]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_PentagramInfo](
	[UserGuid] [int] NOT NULL,
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NULL,
	[JewelPos] [tinyint] NOT NULL,
	[JewelIndex] [smallint] NOT NULL,
	[ItemType] [smallint] NOT NULL,
	[ItemIndex] [int] NOT NULL,
	[MainAttribute] [smallint] NOT NULL,
	[JewelLevel] [smallint] NOT NULL,
	[Rank1] [tinyint] NOT NULL,
	[Rank1Level] [tinyint] NULL,
	[Rank2] [tinyint] NOT NULL,
	[Rank2Level] [tinyint] NULL,
	[Rank3] [tinyint] NOT NULL,
	[Rank3Level] [tinyint] NULL,
	[Rank4] [tinyint] NOT NULL,
	[Rank4Level] [tinyint] NULL,
	[Rank5] [tinyint] NOT NULL,
	[Rank5Level] [tinyint] NULL,
	[RegDate] [datetime] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_MuRummyLog]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_MuRummyLog](
	[mDate] [datetime] NOT NULL,
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[mScore] [int] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_MuRummyInfo]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_MuRummyInfo](
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[mTotalScore] [int] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_MuRummy]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_MuRummy](
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[mSequence] [int] NULL,
	[mNumber] [int] NULL,
	[mColor] [int] NULL,
	[mPosition] [int] NULL,
	[mStatus] [int] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_LUCKY_ITEM_INFO]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_LUCKY_ITEM_INFO](
	[nIndex] [int] IDENTITY(1,1) NOT NULL,
	[UserGuid] [int] NOT NULL,
	[CharName] [varchar](10) NOT NULL,
	[ItemCode] [int] NOT NULL,
	[ItemSerial] [bigint] NOT NULL,
	[DurabilitySmall] [smallint] NOT NULL,
 CONSTRAINT [PK_T_LUCKY_ITEM_INFO] PRIMARY KEY CLUSTERED 
(
	[CharName] ASC,
	[ItemCode] ASC,
	[ItemSerial] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_GMSystem]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_GMSystem](
	[Name] [varchar](10) NOT NULL,
	[AuthorityMask] [int] NOT NULL,
	[Expiry] [smalldatetime] NULL,
 CONSTRAINT [PK_T_GMSystem] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_Event_Inventory]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_Event_Inventory](
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[Inventory] [varbinary](1024) NULL,
 CONSTRAINT [CL_PK_T_Event_Inventory] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_BombHuntLog]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_BombHuntLog](
	[mDate] [datetime] NOT NULL,
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[mScore] [int] NOT NULL,
	[mClear] [tinyint] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[T_BombHunt]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_BombHunt](
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[GameState] [tinyint] NOT NULL,
	[Score] [int] NOT NULL,
	[TileState] [varchar](48) NOT NULL,
 CONSTRAINT [PK_T_BombHunt_Name_AccountID] PRIMARY KEY CLUSTERED 
(
	[Name] ASC,
	[AccountID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[QuestKillCount]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[QuestKillCount](
	[Name] [varchar](10) NOT NULL,
	[QuestIndex] [int] NULL,
	[MonsterClass1] [int] NULL,
	[KillCount1] [int] NULL,
	[MonsterClass2] [int] NULL,
	[KillCount2] [int] NULL,
	[MonsterClass3] [int] NULL,
	[KillCount3] [int] NULL,
	[MonsterClass4] [int] NULL,
	[KillCount4] [int] NULL,
	[MonsterClass5] [int] NULL,
	[KillCount5] [int] NULL,
 CONSTRAINT [PK_QuestKillCount] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[IGC_PeriodItemInfo]    Script Date: 02/21/2019 16:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IGC_PeriodItemInfo](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[UserGUID] [int] NOT NULL,
	[CharacterName] [varchar](10) NOT NULL,
	[ItemType] [smallint] NOT NULL,
	[ItemCode] [smallint] NOT NULL,
	[EffectCategory] [smallint] NOT NULL,
	[EffectType1] [smallint] NOT NULL,
	[EffectType2] [smallint] NULL,
	[Serial] [bigint] NOT NULL,
	[Duration] [int] NOT NULL,
	[BuyDate] [bigint] NOT NULL,
	[ExpireDate] [bigint] NOT NULL,
	[UsedInfo] [int] NOT NULL,
	[BuyDateString] [smalldatetime] NULL,
	[ExpireDateString] [smalldatetime] NULL,
	[SetExpire] [tinyint] NOT NULL,
 CONSTRAINT [PK_IGC_PeriodItemInfo] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_IGC_PeriodItemInfo] UNIQUE NONCLUSTERED 
(
	[Serial] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  StoredProcedure [dbo].[WZ_HuntingRecordLoad_Current]    Script Date: 06/10/2018 12:52:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[WZ_HuntingRecordLoad_Current]
	@szID varchar(10),	@szName varchar(10),	@iMapIndex tinyint,	@iYear int,	@iMonth int,	@iDay int	
AS
BEGIN
	SET NOCOUNT ON;
	SELECT MapIndex,mYear,mMonth,mDay,	CurrentLevel,HuntingAccrueSecond,NormalAccrueDamage,PentagramAccrueDamage,
	HealAccrueValue,MonsterKillCount,AccrueExp,Class,MaxNormalDamage,MinNormalDamage,MaxPentagramDamage,
	MinPentagramDamage,GetNormalAccrueDamage,GetPentagramAccrueDamage
	 FROM HuntingRecordLog WHERE AccountID=@szId AND Name=@szName AND mYear=@iYear AND mMonth=@iMonth  AND mDay=@iDay AND MapIndex=@iMapIndex
END
GO
/****** Object:  StoredProcedure [dbo].[WZ_HuntingRecordLoad]    Script Date: 06/10/2018 12:52:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[WZ_HuntingRecordLoad] 
	@szId varchar (10),
	@szName varchar (10),
	@iMapIndex int
AS
BEGIN
	SET NOCOUNT ON;
	SELECT MapIndex,mYear,mMonth, mDay,
	CurrentLevel,HuntingAccrueSecond,NormalAccrueDamage,PentagramAccrueDamage,HealAccrueValue,MonsterKillCount,
	AccrueExp,Class,MaxNormalDamage,MinNormalDamage,MaxPentagramDamage,MinPentagramDamage,GetNormalAccrueDamage,
	GetPentagramAccrueDamage
	from HuntingRecordLog	where AccountID=@szId and [Name]=@szName and MapIndex=@iMapIndex	
END
GO
/****** Object:  StoredProcedure [dbo].[WZ_HuntingRecordInfoUserOpenSave]    Script Date: 06/10/2018 12:52:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[WZ_HuntingRecordInfoUserOpenSave]
	@szId varchar (10),
	@szName varchar (10),
	@btOpen int
AS
BEGIN
	SET NOCOUNT ON;
	UPDATE Character SET HuntingUserOpen=@btOpen WHERE AccountID=@szId AND Name=@szName	
END
GO
/****** Object:  StoredProcedure [dbo].[WZ_HuntingRecordInfoUserOpenLoad]    Script Date: 06/10/2018 12:52:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[WZ_HuntingRecordInfoUserOpenLoad]
	@szId varchar (10),
	@szName varchar (10)
AS
BEGIN
	SET NOCOUNT ON;
	SELECT HuntingUserOpen FROM Character WHERE AccountID=@szId AND Name=@szName
	
END
GO
/****** Object:  StoredProcedure [dbo].[WZ_HuntingRecordInfoSave]    Script Date: 06/10/2018 12:52:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[WZ_HuntingRecordInfoSave]
	@szID varchar(10),	@szName varchar(10),	@iMapIndex tinyint,	@iYear int,	@iMonth int,	@iDay int,
	@iUserLevel smallint,	@iHuntingTime int,	@iDealDamage bigint,	@iDealElementalDamage bigint,	@iHealAmount bigint,
	@iMonsterKillCount bigint,	@iGainExp bigint,	@iClass smallint,	@iMaxNormalDamage bigint,	@iMinNormalDamage bigint,
	@iMaxPentagramDamage bigint,	@iMinPentagramDamage bigint,	@iGetNormalAccrueDamage bigint,	@iGetPentagramAccrueDamage bigint
AS
BEGIN
	SET NOCOUNT ON;
	IF NOT EXISTS(SELECT Name FROM HuntingRecordLog WHERE Name = @szName AND AccountID=@szID AND MapIndex=@iMapIndex AND 
	mYear=@iYear AND mMonth=@iMonth  AND mDay=@iDay)
	BEGIN
		INSERT INTO HuntingRecordLog (AccountID,Name,MapIndex,mYear,mMonth,mDay,CurrentLevel,HuntingAccrueSecond,NormalAccrueDamage,
		PentagramAccrueDamage,HealAccrueValue,MonsterKillCount,AccrueExp,Class,MaxNormalDamage,MinNormalDamage,
		MaxPentagramDamage,MinPentagramDamage,GetNormalAccrueDamage,GetPentagramAccrueDamage) 
		VALUES (@szID,@szName, @iMapIndex, @iYear,@iMonth,@iDay,@iUserLevel, @iHuntingTime, @iDealDamage, 
		@iDealElementalDamage, @iHealAmount, @iMonsterKillCount, @iGainExp,@iClass,
		@iMaxNormalDamage,@iMinNormalDamage,@iMaxPentagramDamage,@iMinPentagramDamage,@iGetNormalAccrueDamage,@iGetPentagramAccrueDamage)
	END
	ELSE
	BEGIN
		UPDATE HuntingRecordLog SET HuntingAccrueSecond = @iHuntingTime, NormalAccrueDamage = @iDealDamage, 
		PentagramAccrueDamage = @iDealElementalDamage, HealAccrueValue = @iHealAmount, MonsterKillCount = @iMonsterKillCount, 
		AccrueExp = @iGainExp ,Class=@iClass,MaxNormalDamage=@iMaxNormalDamage,MinNormalDamage=@iMinNormalDamage,
		MaxPentagramDamage=@iMaxPentagramDamage,MinPentagramDamage=@iMinPentagramDamage,GetNormalAccrueDamage=@iGetNormalAccrueDamage,
		GetPentagramAccrueDamage=@iGetPentagramAccrueDamage
		WHERE Name = @szName AND AccountID=@szID AND MapIndex =  @iMapIndex AND mYear=@iYear AND mMonth=@iMonth  AND mDay=@iDay
	END
END
--------------------------------------------
GO

/****** Object:  StoredProcedure [dbo].[WZ_HuntingRecordDelete]    Script Date: 06/10/2018 12:52:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[WZ_HuntingRecordDelete]
	@szAccountID varchar(10),
	@szName nchar(10),
	@iMapIndex smallint,
	@iYear smallint,
	@btMonth smallint,
	@btDay smallint
AS
BEGIN
	SET NOCOUNT ON;
        DELETE FROM HuntingRecordLog WHERE AccountID = @szAccountID AND Name = @szName and MapIndex = @iMapIndex AND mYear = @iYear AND  mMonth = @btMonth AND mDay = @btDay
	
END
GO
/****** Object:  Table [dbo].[HuntingRecordLog]    Script Date: 06/10/2018 12:52:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[HuntingRecordLog](
	[AccountID] [varchar](10) NOT NULL,
	[Name] [varchar](10) NOT NULL,
	[MapIndex] [int] NOT NULL,
	[mYear] [int] NULL,
	[mMonth] [int] NULL,
	[mDay] [int] NULL,
	[CurrentLevel] [smallint] NULL,
	[HuntingAccrueSecond] [int] NULL,
	[NormalAccrueDamage] [bigint] NULL,
	[PentagramAccrueDamage] [bigint] NULL,
	[HealAccrueValue] [bigint] NULL,
	[MonsterKillCount] [bigint] NULL,
	[AccrueExp] [bigint] NULL,
	[mDate] [datetime] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  StoredProcedure [dbo].[WZ_GetItemSerial2]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[WZ_GetItemSerial2]

	@iAddSerialCount	int
AS
BEGIN	
	DECLARE @ItemSerial	bigint

	SET NOCOUNT ON
	BEGIN TRANSACTION

	UPDATE GameServerInfo 
	SET @ItemSerial = ItemCount = ItemCount+@iAddSerialCount
		
	IF ( @@error  <> 0 )
	BEGIN
		ROLLBACK TRANSACTION
		SELECT -1
	END
	ELSE
	BEGIN
		COMMIT TRANSACTION	
		SELECT @ItemSerial-@iAddSerialCount+1 AS ItemSerial
	END

	SET NOCOUNT OFF
END
GO
/****** Object:  StoredProcedure [dbo].[WZ_BombHuntSetSelect]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  StoredProcedure [dbo].[WZ_BombHuntSetSelect]    Script Date: 23/06/2018 22:44:50 ******/  
CREATE PROCEDURE [dbo].[WZ_BombHuntSetSelect]
	@AccountID	VARCHAR(10)  
	,@Name		VARCHAR(10)  
AS    
SET NOCOUNT ON  
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED  
  
SELECT Score, GameState, TileState
FROM dbo.T_BombHunt
WHERE AccountID = @AccountID AND Name = @Name
GO
/****** Object:  StoredProcedure [dbo].[WZ_BombHuntSetSave]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  StoredProcedure [dbo].[WZ_BombHuntSetSave]    Script Date: 23/06/2018 22:44:27 ******/
CREATE PROCEDURE [dbo].[WZ_BombHuntSetSave]
	@AccountID	VARCHAR(10)  
	,@Name		VARCHAR(10)  
	,@GameState	TINYINT  
	,@Score		INT  
	,@TileState	VARCHAR(96)
AS    
SET NOCOUNT ON  
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED  
  
UPDATE dbo.T_BombHunt   
SET Score = @Score, GameState = @GameState, TileState = @TileState  
WHERE AccountID = @AccountID AND Name = @Name

IF @@ROWCOUNT = 0 
BEGIN  
	INSERT INTO dbo.T_BombHunt ( AccountID, Name, GameState, Score, TileState)  
	VALUES (@AccountID,@Name,@GameState,@Score,@TileState)  
END
GO
/****** Object:  StoredProcedure [dbo].[WZ_BombHuntSetDelete]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  StoredProcedure [dbo].[WZ_BombHuntSetDelete]    Script Date: 23/06/2018 22:43:49 ******/
CREATE PROCEDURE [dbo].[WZ_BombHuntSetDelete] 
	@AccountID	VARCHAR(10)  
	,@Name		VARCHAR(10)
AS    
SET NOCOUNT ON  
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED  
  
DELETE FROM dbo.T_BombHunt 
WHERE AccountID = @AccountID AND Name = @Name
GO
/****** Object:  StoredProcedure [dbo].[WZ_BombHuntLogSetSave]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  StoredProcedure [dbo].[WZ_BombHuntLogSetSave]    Script Date: 23/06/2018 22:42:42 ******/ 
CREATE PROCEDURE [dbo].[WZ_BombHuntLogSetSave] 
	@AccountID	VARCHAR(10)    
	,@Name		VARCHAR(10)    
	,@Score		INT    
	,@Clear		TINYINT
AS      
SET NOCOUNT ON    
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED    
    
INSERT INTO dbo.[T_BombHuntLog] (mDate, AccountID, Name, mScore, mClear)
VALUES (GETDATE(), @AccountID, @Name, @Score, @Clear)
GO
/****** Object:  View [dbo].[vCharacterPreview]    Script Date: 02/21/2019 16:53:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[vCharacterPreview] AS SELECT Name, cLevel, Class, Inventory, CtlCode FROM dbo.Character
GO
/****** Object:  StoredProcedure [dbo].[IGC_PeriodItemExpiredItemSelectEx]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Dudas [IGCN Team]>
-- Create date: <04.07.2013>
-- Description:	<PeriodItemSystemEx select for expired items procedure>
-- =============================================
CREATE PROCEDURE [dbo].[IGC_PeriodItemExpiredItemSelectEx]
 -- Add the parameters for the stored procedure here
 @UserGUID int,
 @CharacterName varchar(10)

AS
BEGIN
	DECLARE @ErrorCode int

	SET @ErrorCode = 0

	SET NOCOUNT ON

	UPDATE IGC_PeriodItemInfo SET SetExpire = 2 WHERE UserGUID = @UserGUID AND CharacterName = @CharacterName AND ItemType = 2 AND [ExpireDateString] < GETDATE() AND SetExpire = 1

	UPDATE IGC_PeriodItemInfo SET SetExpire = 1 WHERE UserGUID = @UserGUID AND CharacterName = @CharacterName AND ItemType = 2 AND [ExpireDateString] < GETDATE() AND SetExpire = 0

	SELECT * FROM IGC_PeriodItemInfo WHERE UserGUID = @UserGUID AND CharacterName = @CharacterName AND ItemType = 2 AND SetExpire = 1
	IF ( @@Error <> 0 ) BEGIN
		SET @ErrorCode = -1
	END

	SET NOCOUNT OFF
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_PeriodItemDeleteEx]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Dudas [IGCN Team]>
-- Create date: <04.07.2013>
-- Description:	<PeriodItemSystemEx delete procedure>
-- =============================================
CREATE PROCEDURE [dbo].[IGC_PeriodItemDeleteEx]
	-- Add the parameters for the stored procedure here
	@UserGUID int,
	@CharacterName varchar(10),
	@ItemType tinyint,
	@ItemCode smallint,
	@Serial bigint
AS
BEGIN
	DECLARE @ErrorCode int
	DECLARE @ItemInfoCount int

	SET @ErrorCode = 0
	SET @ItemInfoCount = 0

	SET NOCOUNT ON

	IF ( @ItemType = 1 ) BEGIN
		SELECT @ItemInfoCount = COUNT(*) FROM IGC_PeriodItemInfo WHERE UserGUID = @UserGUID AND ItemCode = @ItemCode
		IF ( @ItemInfoCount < 1 ) BEGIN
			SET @ErrorCode = 1
		END
		ELSE BEGIN
			UPDATE IGC_PeriodItemInfo SET UsedInfo = 0 WHERE UserGUID = @UserGUID AND CharacterName = @CharacterName AND ItemCode = @ItemCode
		END
	END
	ELSE IF ( @ItemType = 2 ) BEGIN
		SELECT @ItemInfoCount = COUNT(*) FROM IGC_PeriodItemInfo WHERE UserGUID = @UserGUID AND CharacterName = @CharacterName AND ItemCode = @ItemCode AND Serial = @Serial
		IF ( @ItemInfoCount < 1 ) BEGIN
			SET @ErrorCode = 1
		END
		ELSE BEGIN
			UPDATE IGC_PeriodItemInfo SET UsedInfo = 0 WHERE UserGUID = @UserGUID AND ItemCode = @ItemCode AND Serial = @Serial
		END
	END

	SELECT @ErrorCode

	SET NOCOUNT OFF
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_PeriodBuffSelect]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Dudas [IGCN Team]>
-- Create date: <28.02.2014>
-- Description:	<PeriodBuffSystem select procedure>
-- =============================================
CREATE PROCEDURE [dbo].[IGC_PeriodBuffSelect]
	-- Add the parameters for the stored procedure here
	@CharacterName varchar(10)
AS
BEGIN

	SET NOCOUNT ON;

	SELECT * FROM IGC_PeriodBuffInfo WHERE [CharacterName] = @CharacterName


END
GO
/****** Object:  StoredProcedure [dbo].[IGC_PeriodBuffInsert]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:  <Dudas>
-- Create date: <28.02.2014>
-- Description: <PeriodBuffSystem insert procedure>
-- =============================================
CREATE PROCEDURE [dbo].[IGC_PeriodBuffInsert]
 -- Add the parameters for the stored procedure here
 @CharacterName varchar(10),
 @BuffIndex smallint,
 @EffectType1 smallint,
 @EffectType2 smallint,
 @Duration int,
 @ExpireDate bigint
 
AS
BEGIN
 SET NOCOUNT ON;

    INSERT INTO [dbo].[IGC_PeriodBuffInfo]
           ([CharacterName], [BuffIndex], [EffectType1], [EffectType2], [Duration], [ExpireDate])
     VALUES (@CharacterName, @BuffIndex, @EffectType1, @EffectType2, @Duration, @ExpireDate)

	 SELECT 0 AS QueryResult
END
GO
/****** Object:  StoredProcedure [dbo].[QUEST_PLAYER_INFOSAVE]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[QUEST_PLAYER_INFOSAVE]

	@szCharName		varchar(10),
	@iQuestIndex		INT,
	@iMonsterIndex1	INT,
	@iKillCount1		INT,
	@iMonsterIndex2	INT,
	@iKillCount2		INT,
	@iMonsterIndex3	INT,
	@iKillCount3		INT,
	@iMonsterIndex4	INT,
	@iKillCount4		INT,
	@iMonsterIndex5	INT,
	@iKillCount5		INT
AS
BEGIN
	BEGIN TRANSACTION
	
	SET NOCOUNT ON
	IF EXISTS ( SELECT CHAR_NAME FROM QUEST_PLAYER_INFO  WITH (READUNCOMMITTED) 
				WHERE CHAR_NAME = @szCharName )
	BEGIN
		UPDATE QUEST_PLAYER_INFO
		SET	QuestID	= @iQuestIndex
			, MonsterID1	= @iMonsterIndex1
			, MonsterKillCount1	= @iKillCount1
			, MonsterID2	= @iMonsterIndex2
			, MonsterKillCount2	= @iKillCount2
			, MonsterID3	= @iMonsterIndex3
			, MonsterKillCount3	= @iKillCount3
			, MonsterID4	= @iMonsterIndex4
			, MonsterKillCount4	= @iKillCount4
			, MonsterID5	= @iMonsterIndex5
			, MonsterKillCount5	= @iKillCount5
		WHERE CHAR_NAME = @szCharName
	END
	ELSE
	BEGIN
		INSERT QUEST_PLAYER_INFO VALUES ( @szCharName, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 )

		UPDATE QUEST_PLAYER_INFO
		SET	QuestID	= @iQuestIndex
			, MonsterID1	= @iMonsterIndex1
			, MonsterKillCount1	= @iKillCount1
			, MonsterID2	= @iMonsterIndex2
			, MonsterKillCount2	= @iKillCount2
			, MonsterID3	= @iMonsterIndex3
			, MonsterKillCount3	= @iKillCount3
			, MonsterID4	= @iMonsterIndex4
			, MonsterKillCount4	= @iKillCount4
			, MonsterID5	= @iMonsterIndex5
			, MonsterKillCount5	= @iKillCount5
		WHERE CHAR_NAME = @szCharName
	END
	
	IF(@@Error <> 0 )
		ROLLBACK TRANSACTION
	ELSE	
		COMMIT TRANSACTION
	SET NOCOUNT OFF	
END
GO
/****** Object:  StoredProcedure [dbo].[QUEST_PLAYER_INFOLOAD]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[QUEST_PLAYER_INFOLOAD]

	@szCharName	varchar(10)
AS
BEGIN
	BEGIN TRANSACTION
	
	SET NOCOUNT ON
	IF EXISTS ( SELECT CHAR_NAME FROM QUEST_PLAYER_INFO  WITH ( READUNCOMMITTED ) 
				WHERE CHAR_NAME = @szCharName )
	BEGIN
		SELECT QuestID, MonsterID1, MonsterKillCount1, MonsterID2, MonsterKillCount2, MonsterID3, MonsterKillCount3, MonsterID4, MonsterKillCount4, MonsterID5, MonsterKillCount5
			FROM QUEST_PLAYER_INFO  WHERE CHAR_NAME = @szCharName
	END
	ELSE
	BEGIN
		INSERT QUEST_PLAYER_INFO VALUES ( @szCharName, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 )
		SELECT QuestID, MonsterID1, MonsterKillCount1, MonsterID2, MonsterKillCount2, MonsterID3, MonsterKillCount3, MonsterID4, MonsterKillCount4, MonsterID5, MonsterKillCount5
			FROM QUEST_PLAYER_INFO  WHERE CHAR_NAME = @szCharName
	END
	
	IF(@@Error <> 0 )
		ROLLBACK TRANSACTION
	ELSE	
		COMMIT TRANSACTION
	SET NOCOUNT OFF	
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_SetUpdateMuRummy]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[IGC_SetUpdateMuRummy] (
	@AccountID	VARCHAR(10)
,	@Name		VARCHAR(10)
,	@Position	INT
,	@Status		INT
,	@Sequence	INT
)
AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	UPDATE dbo.T_MuRummy SET mPosition = @Position, mStatus = @Status 
	WHERE AccountID = @AccountID AND Name = @Name AND mSequence = @Sequence
GO
/****** Object:  StoredProcedure [dbo].[IGC_SetSelectMuRummy]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[IGC_SetSelectMuRummy] (
	@AccountID	VARCHAR(10)
,	@Name		VARCHAR(10)
)
AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	SELECT a.AccountID,a.Name,a.mTotalScore,b.mColor,b.mNumber,b.mPosition,b.mStatus,b.mSequence
	FROM dbo.T_MuRummyInfo a INNER JOIN dbo.T_MuRummy b ON a.Name = b.Name
	WHERE a.AccountID = @AccountID AND a.Name = @Name
GO
/****** Object:  StoredProcedure [dbo].[IGC_SetSaveMuRummyLog]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[IGC_SetSaveMuRummyLog] (
	@AccountID	VARCHAR(10)
,	@Name		VARCHAR(10)
,	@Score	INT
)
AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	INSERT INTO dbo.T_MuRummyLog ( mDate, AccountID, Name, mScore)	VALUES (GETDATE(), @AccountID,@Name,@Score);
GO
/****** Object:  StoredProcedure [dbo].[IGC_SetSaveMuRummyInfo]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[IGC_SetSaveMuRummyInfo] (
	@AccountID	VARCHAR(10)
,	@Name		VARCHAR(10)
,	@TotalScore	INT
)
AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	UPDATE dbo.T_MuRummyInfo SET mTotalScore = @TotalScore WHERE AccountID = @AccountID AND Name = @Name
	IF @@ROWCOUNT = 0
	BEGIN
		INSERT INTO dbo.T_MuRummyInfo ( AccountID, Name, mTotalScore)
		VALUES (@AccountID,@Name,0);
	END
GO
/****** Object:  StoredProcedure [dbo].[IGC_SetSaveEventInventory]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[IGC_SetSaveEventInventory] (
	@AccountID	VARCHAR(10)
,	@Name		VARCHAR(10)
,	@Inventory	VARBINARY(1024)	-- 32 * 32
)
AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	UPDATE dbo.T_Event_Inventory SET Inventory = @Inventory WHERE AccountID = @AccountID AND Name = @Name
	IF @@ROWCOUNT = 0
	BEGIN
		SET @Inventory = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
		
		INSERT INTO dbo.T_Event_Inventory ( AccountID, Name, Inventory)
		VALUES (@AccountID,@Name,@Inventory);
	END
GO
/****** Object:  StoredProcedure [dbo].[IGC_SetInsertMuRummy]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[IGC_SetInsertMuRummy] (
	@AccountID	VARCHAR(10)
,	@Name		VARCHAR(10)
,	@Number		INT
,	@Color		INT
,	@Position	INT
,	@Status		INT
,	@Sequence	INT
)
AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	INSERT INTO dbo.T_MuRummy ( AccountID, Name, mNumber, mColor, mPosition, mStatus, mSequence)
	VALUES (@AccountID,@Name,@Number,@Color,@Position,@Status,@Sequence);
GO
/****** Object:  StoredProcedure [dbo].[IGC_PeriodItemSelectEx]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Dudas [IGCN Team]>
-- Create date: <04.07.2013>
-- Description:	<PeriodItemSystemEx select procedure>
-- =============================================
CREATE PROCEDURE [dbo].[IGC_PeriodItemSelectEx]
	-- Add the parameters for the stored procedure here
	@UserGUID int,
	@CharacterName varchar(10)
AS
BEGIN
	DECLARE @ErrorCode int

	SET @ErrorCode = 0

	SET NOCOUNT ON

	UPDATE IGC_PeriodItemInfo SET UsedInfo = 0 WHERE UserGUID = @UserGUID AND CharacterName = @CharacterName AND UsedInfo = 1 AND ExpireDateString < GetDate()

	SELECT * FROM IGC_PeriodItemInfo WHERE UserGUID = @UserGUID AND CharacterName = @CharacterName AND UsedInfo = 1
	IF ( @@Error <> 0 ) BEGIN
		SET @ErrorCode = -1
	END

	SET NOCOUNT OFF
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_PeriodItemInsertEx]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:  <Dudas (IGC)>
-- Create date: <31.08.2015>
-- Description: <PeriodItemSystemEx insert procedure (update)>
-- =============================================
CREATE PROCEDURE [dbo].[IGC_PeriodItemInsertEx]
 @UserGUID int,
 @CharacterName varchar(10),
 @ItemType smallint,
 @ItemCode smallint,
 @EffectCategory smallint,
 @EffectType1 smallint,
 @EffectType2 smallint,
 @Serial bigint,
 @Duration int,
 @BuyDate bigint,
 @ExpireDate bigint
 
AS
BEGIN
	DECLARE @ErrorCode int
	DECLARE @PeriodItemIndex int

	SET @ErrorCode = 0
	SET @PeriodItemIndex = 0

	SET XACT_ABORT ON
	SET NOCOUNT ON		
	BEGIN TRANSACTION

	DECLARE @CalcExpireDate smalldatetime

	SELECT @CalcExpireDate = DATEADD( second, @Duration, GETDATE() )

	IF ( @ItemType = 1 ) BEGIN
		SELECT @PeriodItemIndex = id FROM IGC_PeriodItemInfo WHERE UserGUID = @UserGUID AND CharacterName = @CharacterName AND UsedInfo = 1 AND EffectCategory = @EffectCategory
		IF( @PeriodItemIndex <> 0 ) BEGIN
			UPDATE IGC_PeriodItemInfo SET UsedInfo = 0 WHERE id = @PeriodItemIndex
		END

		INSERT INTO IGC_PeriodItemInfo ( UserGUID, CharacterName, ItemCode, ItemType, EffectType1, EffectType2, Duration, BuyDateString, ExpireDateString, UsedInfo, EffectCategory, Serial, BuyDate, ExpireDate )
		VALUES
		( @UserGUID, @CharacterName, @ItemCode, @ItemType, @EffectType1, @EffectType2, @Duration, GETDATE(), @CalcExpireDate, 1, @EffectCategory, @Serial, @BuyDate, @ExpireDate )
		iF ( @@Error <> 0 ) BEGIN
			SET @ErrorCode = 2
		END
	END
	ELSE IF ( @ItemType = 2 ) BEGIN
		INSERT INTO IGC_PeriodItemInfo ( UserGUID, CharacterName, ItemCode, ItemType, EffectType1, EffectType2, Duration, BuyDateString, ExpireDateString, UsedInfo, EffectCategory, Serial, BuyDate, ExpireDate )
		VALUES
		( @UserGUID, @CharacterName, @ItemCode, @ItemType, 0, 0, @Duration, GETDATE(), @CalcExpireDate, 1, 0, @Serial, @BuyDate, @ExpireDate )
		iF ( @@Error <> 0 ) BEGIN
			SET @ErrorCode = 2
		END
	END

	IF ( @ErrorCode <> 0 )
		ROLLBACK TRANSACTION
	ELSE
		COMMIT TRANSACTION

	SELECT @ErrorCode

	SET NOCOUNT OFF
	SET XACT_ABORT OFF
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_PeriodBuffDeleteGuild]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Dudas [IGCN Team]>
-- Create date: <28.02.2014>
-- Description:	<PeriodBuffSystem delete procedure for guilds>
-- =============================================
CREATE PROCEDURE [dbo].[IGC_PeriodBuffDeleteGuild]
	-- Add the parameters for the stored procedure here
	@BuffIndex int
AS
BEGIN
	SET NOCOUNT ON;

	DELETE FROM IGC_PeriodBuffInfo WHERE [BuffIndex] = @BuffIndex

	SELECT 0 AS QueryResult

END
GO
/****** Object:  StoredProcedure [dbo].[IGC_PeriodBuffDelete]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Dudas [IGCN Team]>
-- Create date: <28.02.2014>
-- Description:	<PeriodBuffSystem delete procedure>
-- =============================================
CREATE PROCEDURE [dbo].[IGC_PeriodBuffDelete]
	-- Add the parameters for the stored procedure here
	@CharacterName varchar(10),
	@BuffIndex int
AS
BEGIN
	SET NOCOUNT ON;

	DELETE FROM IGC_PeriodBuffInfo WHERE [CharacterName] = @CharacterName AND [BuffIndex] = @BuffIndex

	SELECT 0 AS QueryResult

END
GO
/****** Object:  StoredProcedure [dbo].[IGC_PentagramInfoUpdate]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE   PROC [dbo].[IGC_PentagramInfoUpdate]
	@UserGuid	INT,
	@AccountID	VARCHAR(10),
	@Name		VARCHAR(10),
	@JewelPos	TINYINT,
	@JewelIndex	SMALLINT,
	@ItemType	SMALLINT,
	@ItemIndex	INT,
	@MainAttribute	SMALLINT,
	@JewelLevel	SMALLINT,
	@Rank1		TINYINT,
	@Rank1Level	TINYINT,
	@Rank2		TINYINT,
	@Rank2Level	TINYINT,
	@Rank3		TINYINT,
	@Rank3Level	TINYINT,
	@Rank4		TINYINT,
	@Rank4Level	TINYINT,
	@Rank5		TINYINT,
	@Rank5Level	TINYINT
	AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
	SET XACT_ABORT ON
	
	
	DECLARE  @Result  INT
	SET 	   @Result = 0        
	
	BEGIN TRAN 
	
	IF EXISTS ( SELECT TOP 1 JewelIndex FROM dbo.T_PentagramInfo  
	WHERE 	AccountID = @AccountID AND JewelPos  = @JewelPos AND JewelIndex = @JewelIndex )
	BEGIN
	
		IF (@JewelPos = 0)
		BEGIN
	
			IF EXISTS ( SELECT TOP 1 JewelIndex FROM dbo.T_PentagramInfo  
			WHERE 	AccountID = @AccountID AND Name = @Name 
			AND JewelPos  = @JewelPos AND JewelIndex = @JewelIndex )
			BEGIN
				UPDATE	dbo.T_PentagramInfo
				SET	JewelIndex = @JewelIndex
				,ItemType	= @ItemType
				,ItemIndex	= @ItemIndex
				,MainAttribute	= @MainAttribute
				,JewelLevel = @JewelLevel
				,Rank1 = Rank1
				,Rank1Level = @Rank1Level	
				,Rank2 = Rank2
				,Rank2Level = @Rank2Level
				,Rank3 = Rank3
				,Rank3Level = @Rank3Level
				,Rank4 = Rank4
				,Rank4Level = @Rank4Level
				,Rank5 = Rank5
				,Rank5Level = @Rank5Level 
				WHERE
					AccountID = @AccountID	
				AND	Name	   = @Name		
				AND	JewelPos  = @JewelPos
				AND JewelIndex = @JewelIndex	
	
			END
			ELSE
			BEGIN
				INSERT	dbo.T_PentagramInfo
						(UserGuid,AccountID,Name,JewelPos,JewelIndex,ItemType,ItemIndex,MainAttribute,JewelLevel,Rank1, Rank1Level, Rank2, Rank2Level, Rank3, Rank3Level, Rank4, Rank4Level, Rank5, Rank5Level)
				SELECT	@UserGuid,@AccountID,@Name,@JewelPos,@JewelIndex,@ItemType,@ItemIndex,@MainAttribute,@JewelLevel,@Rank1,@Rank1Level,@Rank2,@Rank2Level,@Rank3,@Rank3Level,@Rank4,@Rank4Level,@Rank5,@Rank5Level
			END		
		END
		ELSE
		BEGIN
	
			UPDATE	dbo.T_PentagramInfo
			SET	JewelIndex = @JewelIndex
			,ItemType	= @ItemType
			,ItemIndex	= @ItemIndex
			,MainAttribute	= @MainAttribute
			,JewelLevel = @JewelLevel
			,Rank1 = Rank1
			,Rank1Level = @Rank1Level	
			,Rank2 = Rank2
			,Rank2Level = @Rank2Level
			,Rank3 = Rank3
			,Rank3Level = @Rank3Level
			,Rank4 = Rank4
			,Rank4Level = @Rank4Level
			,Rank5 = Rank5
			,Rank5Level = @Rank5Level
			WHERE	
				AccountID = @AccountID	
			AND	JewelPos  = @JewelPos
			AND JewelIndex = @JewelIndex	
	
		END	
	
		IF @@ERROR <> 0 GOTO ERROR_HANDLING        
	  
	END
	ELSE
	BEGIN
		INSERT	dbo.T_PentagramInfo
				(UserGuid,AccountID,Name,JewelPos,JewelIndex,ItemType,ItemIndex,MainAttribute,JewelLevel,Rank1, Rank1Level, Rank2, Rank2Level, Rank3, Rank3Level, Rank4, Rank4Level, Rank5, Rank5Level)
		SELECT	@UserGuid,@AccountID,@Name,@JewelPos,@JewelIndex,@ItemType,@ItemIndex,@MainAttribute,@JewelLevel,@Rank1,@Rank1Level,@Rank2,@Rank2Level,@Rank3,@Rank3Level,@Rank4,@Rank4Level,@Rank5,@Rank5Level
		
		IF @@ERROR <> 0 GOTO ERROR_HANDLING        		   
	 
	END
	
	COMMIT TRAN
	RETURN
	
	ERROR_HANDLING:      
	ROLLBACK TRAN    
	SET @Result = 1        
	RETURN          
	        
	
	SET XACT_ABORT OFF
	SET NOCOUNT OFF
GO
/****** Object:  StoredProcedure [dbo].[IGC_PentagramInfoSelect]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROC [dbo].[IGC_PentagramInfoSelect]
	@UserGuid	INT,
	@AccountID	VARCHAR(10),
	@Name		VARCHAR(10),
	@JewelPos	TINYINT
	AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
	
	IF (@JewelPos = 0)
	BEGIN
	
		SELECT	JewelIndex,ItemType,ItemIndex,MainAttribute,JewelLevel,Rank1, Rank1Level, Rank2, Rank2Level, Rank3, Rank3Level, Rank4, Rank4Level, Rank5, Rank5Level
		FROM	dbo.T_PentagramInfo
		WHERE	AccountID	= @AccountID	
		AND	Name		= @Name		
		AND	JewelPos	= @JewelPos	
	
	END
	ELSE
	BEGIN
	
		SELECT	JewelIndex,ItemType,ItemIndex,MainAttribute,JewelLevel,Rank1, Rank1Level, Rank2, Rank2Level, Rank3, Rank3Level, Rank4, Rank4Level, Rank5, Rank5Level
		FROM	dbo.T_PentagramInfo
		WHERE	AccountID	= @AccountID	
		AND	JewelPos	= @JewelPos	
	
	END
	
	
	SET NOCOUNT OFF
GO
/****** Object:  StoredProcedure [dbo].[IGC_PentagramInfoDelete]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE   PROC [dbo].[IGC_PentagramInfoDelete]
	@UserGuid	INT,
	@AccountID	VARCHAR(10),
	@Name		VARCHAR(10),
	@JewelPos	TINYINT,
	@JewelIndex	smallint
	AS  
	SET NOCOUNT ON
	SET XACT_ABORT ON 
	
	IF (@JewelPos = 0)
	BEGIN
	
		DELETE	T_PentagramInfo 
		WHERE
			AccountID	= @AccountID	
			AND	Name		= @Name		
			AND	JewelPos	= @JewelPos
			AND	JewelIndex	= @JewelIndex
	
	END
	ELSE
	BEGIN
	
		DELETE	T_PentagramInfo 
		WHERE
			AccountID	= @AccountID	
			AND	JewelPos	= @JewelPos
			AND	JewelIndex	= @JewelIndex
	
	END
	
	SET XACT_ABORT OFF
	SET NOCOUNT OFF
GO
/****** Object:  StoredProcedure [dbo].[IGC_LuckyItemSelect]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROC [dbo].[IGC_LuckyItemSelect]
	@CharacterName varchar(10)  
	AS  
	SELECT	ItemCode, ItemSerial, DurabilitySmall 
	FROM	T_LUCKY_ITEM_INFO 
	WHERE	CharName = @CharacterName
GO
/****** Object:  StoredProcedure [dbo].[IGC_LuckyItemInsert]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROC  [dbo].[IGC_LuckyItemInsert]  
	@UserGuid 			int
	,@CharName			varchar(10)
	,@ItemCode			int
	,@ItemSerial		bigint
	,@DurabilitySmall	smallint
	AS         
	DECLARE @ErrorCode int        
	SET	@ErrorCode = 0        
	
	SET NOCOUNT ON    
	SET	XACT_ABORT ON
	        
	BEGIN TRAN
	
	IF NOT EXISTS (SELECT ItemCode FROM T_LUCKY_ITEM_INFO  WITH ( READUNCOMMITTED )         
	WHERE CharName = @CharName AND ItemCode = @ItemCode AND ItemSerial  = @ItemSerial
	and	UserGuid = @UserGuid)
	BEGIN            
		INSERT INTO T_LUCKY_ITEM_INFO (UserGuid, CharName, ItemCode, ItemSerial, DurabilitySmall) 
		VALUES  (@UserGuid, @CharName, @ItemCode, @ItemSerial, @DurabilitySmall)    
	END       
	
	ELSE        
	BEGIN    
		UPDATE T_LUCKY_ITEM_INFO 
		SET	DurabilitySmall = @DurabilitySmall
		WHERE CharName = @CharName AND ItemCode = @ItemCode AND ItemSerial  = @ItemSerial 
		and	UserGuid = @UserGuid
	END        
	
	IF( @@Error <> 0 )        
	BEGIN        
	SET @ErrorCode = 2        
	END        
	
	IF ( @ErrorCode  <> 0 ) 
	ROLLBACK TRAN       
	ELSE        
	COMMIT TRAN
	
	SELECT @ErrorCode        
	
	SET	XACT_ABORT OFF        
	SET NOCOUNT OFF
GO
/****** Object:  StoredProcedure [dbo].[IGC_LuckyItemDelete]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROC  [dbo].[IGC_LuckyItemDelete]
	@CharacterName varchar(10)
	,@ItemCode	int
	,@ItemSerial	bigint
	AS  
	DELETE	T_LUCKY_ITEM_INFO 
	WHERE	CharName = @CharacterName AND ItemCode = @ItemCode AND ItemSerial = @ItemSerial
GO
/****** Object:  StoredProcedure [dbo].[IGC_GetLoadEventInventory]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[IGC_GetLoadEventInventory] (
	@AccountID	VARCHAR(10)
,	@Name		VARCHAR(10)
)
AS  
	SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DECLARE @Inventory VARBINARY(1024)    
	DECLARE @OldAccountID VARCHAR(10)
	
	SELECT @OldAccountID = AccountID FROM dbo.T_Event_Inventory WHERE Name = @Name
	IF @OldAccountID <> @AccountID 
	BEGIN
		DELETE FROM T_Event_Inventory WHERE AccountID = @OldAccountID and Name = @Name
	END
	
	
	SELECT @Inventory = Inventory FROM dbo.T_Event_Inventory WHERE AccountID = @AccountID AND Name = @Name
	IF @@ROWCOUNT = 0
	BEGIN
		SET @Inventory = [encoded data, 5227 characters]
		
		INSERT INTO dbo.T_Event_Inventory ( AccountID, Name, Inventory)
		VALUES (@AccountID,@Name,@Inventory);
	END

	SELECT @Inventory
GO
/****** Object:  StoredProcedure [dbo].[IGC_DevilSquareFinal_SetReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_DevilSquareFinal_SetReward]	
	@mAccountID varchar(10),
	@mName varchar(10),
	@mClass int,
	@mDSFType tinyint,
	@mRewardYear int,
	@mRewardMonth int,
	@mRewardStartDay int,
	@mRewardEndDay int
AS
BEGIN
	SET NOCOUNT ON;

    INSERT INTO IGC_DevilSquareFinal_Rewards (mAccountID, mName, mClass, mDSFType, mRewardYear, mRewardMonth, mRewardStartDay, mRewardEndDay, mRewardGain) VALUES
	(@mAccountID, @mName, @mClass, @mDSFType, @mRewardYear, @mRewardMonth, @mRewardStartDay, @mRewardEndDay, 0)
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_DevilSquareFinal_Save]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[IGC_DevilSquareFinal_Save]
	@mAccountID1	VARCHAR(10),
	@mName1			VARCHAR(10),
	@mUserLevel1	INT,
	@mAccountID2	VARCHAR(10),
	@mName2			VARCHAR(10),
	@mUserLevel2	INT,
	@mPoint			INT,
	@mDSFType		TINYINT,
	@mEnterCount	TINYINT
AS
    SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DECLARE	 
				 @aRowCnt		INT
				,@aErrNo		INT
				,@Result		TINYINT
	SELECT		 
				 @aRowCnt = 0
				,@aErrNo = 0
				,@Result = 1

	UPDATE dbo.IGC_DevilSquareFinal_Scores SET mPoint = mPoint + @mPoint, mEnterCount = mEnterCount + @mEnterCount, mDate = GETDATE() WHERE mAccountID1 = @mAccountID1 AND mAccountID2 = @mAccountID2 AND
	mName1 = @mName1 AND mName2 = @mName2 AND mUserLevel1 = @mUserLevel1 AND mUserLevel2 = @mUserLevel2 AND mDSFType = @mDSFType

	SELECT @aErrNo = @@ERROR, @aRowCnt = @@ROWCOUNT
	IF (@aErrNo <> 0)
	BEGIN
		SET @Result = -1
		SELECT @Result
		RETURN 
	END
		
	IF (@aRowCnt = 0)
	BEGIN
		INSERT INTO dbo.IGC_DevilSquareFinal_Scores ( mAccountID1, mName1, mUserLevel1, mAccountID2, mName2, mUserLevel2, mDSFType, mPoint, mEnterCount, mDate ) 
		VALUES ( @mAccountID1, @mName1, @mUserLevel1, @mAccountID2, @mName2, @mUserLevel2, @mDSFType, @mPoint, @mEnterCount, GETDATE() )
		SELECT @aErrNo = @@ERROR, @aRowCnt = @@ROWCOUNT
		IF ( @aErrNo <> 0 OR @aRowCnt = 0)
		BEGIN
			SET @Result = -2
			SELECT @Result
			RETURN
		END
	END

	SET @Result = 0
	SELECT @Result
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[IGC_DevilSquareFinal_Renew]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROC [dbo].[IGC_DevilSquareFinal_Renew]
	@mDSFType		TINYINT
AS
    SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DELETE FROM dbo.IGC_DevilSquareFinal_Ranking WHERE mDSFType = @mDSFType;

	DECLARE @mTbl TABLE (
		mRank			INT IDENTITY (1,1)	NOT NULL
	,	mUserName1		VARCHAR(10)		NOT NULL
	,	mUserName2		VARCHAR(10)		NOT NULL
	,	mServerCode1	INT				NOT NULL
	,	mServerCode2	INT				NOT NULL
	,	mDSFType		TINYINT			NOT NULL
	,	mPoint			INT				NOT NULL
	,	mEnterCount		INT				NOT NULL
	)

	INSERT INTO @mTbl (
	mUserName1,mUserName2,mServerCode1,mServerCode2,mDSFType,mPoint,mEnterCount	)
	SELECT 
		A.mName1,A.mName2,B.ServerCode,C.ServerCode,@mDSFType,A.mPoint,A.mEnterCount
	FROM IGC_DevilSquareFinal_Scores A JOIN BattleCoreInfo B ON A.mName1 = B.Name JOIN BattleCoreInfo C ON A.mName2 = C.Name
	WHERE mDSFType = @mDSFType
	ORDER BY A.mPoint desc, (A.mUserLevel1+A.mUserLevel2) asc

    INSERT INTO dbo.IGC_DevilSquareFinal_Ranking WITH(TABLOCK)
        ( mRank, mUserName1, mUserName2, mServerCode1, mServerCode2, mDSFType, mPoint, mEnterCount, mDate )
	SELECT mRank, mUserName1, mUserName2, mServerCode1, mServerCode2, mDSFType, mPoint, mEnterCount, GETDATE() FROM @mTbl
GO
/****** Object:  StoredProcedure [dbo].[IGC_DevilSquareFinal_GetReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_DevilSquareFinal_GetReward]
	@mAccountID varchar(10),
	@mName varchar(10),
	@mRewardYear int,
	@mRewardMonth int,
	@mRewardDay int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM IGC_DevilSquareFinal_Rewards WHERE mAccountID = @mAccountID AND mName = @mName AND mRewardYear = @mRewardYear AND mRewardMonth = @mRewardMonth)
	BEGIN
		SELECT 1 AS Result
		RETURN
	END

	DECLARE @mRewardStartDay int
	DECLARE @mRewardEndDay int
	DECLARE @mRewardGain int

	SELECT @mRewardStartDay = mRewardStartDay, @mRewardEndDay = mRewardEndDay, @mRewardGain = mRewardGain FROM IGC_DevilSquareFinal_Rewards WHERE mAccountID = @mAccountID AND mName = @mName AND mRewardYear = @mRewardYear AND mRewardMonth = @mRewardMonth

	IF @mRewardDay < @mRewardStartDay OR @mRewardDay > @mRewardEndDay
	BEGIN
		SELECT 1 AS Result
		RETURN
	END

	IF @mRewardGain = 1
	BEGIN
		SELECT 1 AS Result
		RETURN
	END

	UPDATE IGC_DevilSquareFinal_Rewards SET mRewardGain = 1 WHERE mAccountID = @mAccountID AND mName = @mName AND mRewardYear = @mRewardYear AND mRewardMonth = @mRewardMonth
	SELECT 0 AS Result
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_DevilSquareFinal_GetRank_r]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROC [dbo].[IGC_DevilSquareFinal_GetRank_r]
	@mDSFType		TINYINT
AS
    SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DECLARE @mTbl TABLE (
		mRank			INT IDENTITY (1,1)	NOT NULL
	,	mUserName1		VARCHAR(10)		NOT NULL
	,	mUserName2		VARCHAR(10)		NOT NULL
	,	mServerCode1	INT				NOT NULL
	,	mServerCode2	INT				NOT NULL
	,	mDSFType		TINYINT			NOT NULL
	,	mPoint			INT				NOT NULL
	,	mEnterCount		INT				NOT NULL
	,	mDate			SMALLDATETIME	NOT NULL
	)
	

	DECLARE @RankCount int

	IF @mDSFType = 2
	BEGIN
		SET @RankCount = 40
	END
	ELSE IF @mDSFType = 3
	BEGIN
		SET @RankCount = 10
	END
	ELSE IF @mDSFType = 4
	BEGIN
		SET @RankCount = 1
	END

	INSERT INTO @mTbl (mUserName1, mUserName2, mServerCode1, mServerCode2, mDSFType, mPoint, mEnterCount, mDate) 
	SELECT TOP(@RankCount) B.UBFName, C.UBFName, A.mServerCode1, A.mServerCode2, A.mDSFType, A.mPoint, A.mEnterCount, A.mDate
	FROM dbo.IGC_DevilSquareFinal_Ranking A JOIN BattleCoreInfo B ON A.mUserName1 = B.Name JOIN BattleCoreInfo C ON A.mUserName2 = C.Name
	WHERE mDSFType = @mDSFType
	ORDER BY mRank

	SELECT mRank, mUserName1, mUserName2, mServerCode1, mServerCode2, mDSFType, mPoint, mEnterCount,
	DATEPART(YEAR, mDate) AS mYear, DATEPART(MONTH, mDate) AS mMonth, DATEPART(DAY, mDate) AS mDay FROM @mTbl
GO
/****** Object:  StoredProcedure [dbo].[IGC_DevilSquareFinal_CanPartyEnter]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROC [dbo].[IGC_DevilSquareFinal_CanPartyEnter]
	@mAccountID1	VARCHAR(10),
	@mName1			VARCHAR(10),
	@mAccountID2	VARCHAR(10),
	@mName2			VARCHAR(10),
	@mDSFType		TINYINT
AS
    SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DECLARE	 
				 @aRowCnt		INT
				,@aErrNo		INT
				,@Result		TINYINT
				,@mRank			INT
				,@mEnterCnt		INT
	SELECT		 
				 @aRowCnt = 0
				,@aErrNo = 0
				,@Result = 1
				,@mRank = 0
				,@mEnterCnt = 0

	SELECT @mRank = mRank, @mEnterCnt = mEnterCount
	FROM dbo.IGC_DevilSquareFinal_Ranking
	WHERE mDSFType = @mDSFType AND mUserName1 = @mName1 AND mUserName2 = @mName2

	SELECT @aErrNo = @@ERROR, @aRowCnt = @@ROWCOUNT
	PRINT @mRank
	PRINT @aRowCnt
	IF @mDSFType = 2
	BEGIN
		IF ( @mRank > 40 OR @aRowCnt = 0)
		BEGIN
			SET @Result = 1
			SELECT @Result AS Result
			RETURN
		END
	END
	ELSE IF @mDSFType = 3
	BEGIN
		IF ( @mRank > 10 OR @aRowCnt = 0)
		BEGIN
			SET @Result = 1
			SELECT @Result AS Result
			RETURN
		END
	END

	IF @mDSFType = 1
	BEGIN
		SET @Result = 0
	END
	ELSE IF @mDSFType = 2 OR @mDSFType = 3
	BEGIN
		SET @Result = 4
	END
	SELECT @Result AS Result, @mEnterCnt AS EnterCount
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[IGC_ChaosCastleFinal_Save]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROC [dbo].[IGC_ChaosCastleFinal_Save]
	@mName			VARCHAR(10)
,	@mPoint			INT
,	@mCharClass		INT
,	@mCharLevel		INT
,	@mCharExp		BIGINT
,	@mCCFType		TINYINT
AS
    SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DECLARE	 
				 @aRowCnt		INT
				,@aErrNo		INT
				,@Result		TINYINT
	SELECT		 
				 @aRowCnt = 0
				,@aErrNo = 0
				,@Result = 1

	UPDATE dbo.IGC_ChaosCastleFinal_Scores SET mPoint = mPoint + @mPoint, mCharClass = @mCharClass, mCharLevel = @mCharLevel, mCharExperience = @mCharExp, mDate = GETDATE() WHERE mName = @mName AND mCCFType = @mCCFType 
	SELECT @aErrNo = @@ERROR, @aRowCnt = @@ROWCOUNT
	IF (@aErrNo <> 0)
	BEGIN
		SET @Result = -1
		SELECT @Result
		RETURN 
	END
		
	IF (@aRowCnt = 0)
	BEGIN
		INSERT INTO dbo.IGC_ChaosCastleFinal_Scores ( mName, mCCFType, mPoint, mCharClass, mCharLevel, mCharExperience, mDate ) 
		VALUES ( @mName, @mCCFType,@mPoint, @mCharClass, @mCharLevel, @mCharExp, GETDATE() )
		SELECT @aErrNo = @@ERROR, @aRowCnt = @@ROWCOUNT
		IF ( @aErrNo <> 0 OR @aRowCnt = 0)
		BEGIN
			SET @Result = -2
			SELECT @Result
			RETURN
		END
	END

	SET @Result = 0
	SELECT @Result
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[IGC_ChaosCastleFinal_Renew]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROC [dbo].[IGC_ChaosCastleFinal_Renew]
	@mCCFType		TINYINT
AS
    SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DELETE FROM dbo.IGC_ChaosCastleFinal_Ranking WHERE mCCFType = @mCCFType;

	DECLARE @mTbl TABLE (
		mRank INT IDENTITY (1,1)	NOT NULL
	,	mName		VARCHAR(10)		NOT NULL
	,	mCCFType	TINYINT			NOT NULL
	,	mClass		INT				NOT NULL
	,	mPoint		INT				NOT NULL
	) 
	INSERT INTO @mTbl (
	mName,mCCFType,mClass,mPoint	)
	SELECT 
		mName,@mCCFType,mCharClass,mPoint
	FROM IGC_ChaosCastleFinal_Scores
	WHERE mCCFType = @mCCFType
	ORDER BY mPoint DESC, mCharLevel ASC, mCharExperience ASC

    INSERT INTO dbo.IGC_ChaosCastleFinal_Ranking WITH(TABLOCK)
        ( mRank, mName, mCCFType, mClass, mPoint, mDate )
	SELECT mRank, mName, mCCFType, mClass, mPoint, GETDATE() FROM @mTbl
GO
/****** Object:  StoredProcedure [dbo].[IGC_ChaosCastleFinal_GetRank_r]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROC [dbo].[IGC_ChaosCastleFinal_GetRank_r]
	@mCCFType		TINYINT
AS
    SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DECLARE @mTbl TABLE (
		mRank int,
		mName varchar(10),
		mClass int,
		mPoint int )

	INSERT INTO @mTbl (mRank, mName, mClass, mPoint) 
	SELECT TOP 50 A.mRank, B.UBFName, A.mClass, A.mPoint
	FROM dbo.IGC_ChaosCastleFinal_Ranking A JOIN BattleCoreInfo B ON A.mName = B.Name
	WHERE mCCFType = @mCCFType
	ORDER BY mRank

	SELECT mRank, mName, mClass, mPoint FROM @mTbl
GO
/****** Object:  StoredProcedure [dbo].[IGC_ChaosCastleFinal_GetPermission]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROC [dbo].[IGC_ChaosCastleFinal_GetPermission]
	@mName			VARCHAR(10),
	@mCCFType		TINYINT
AS
    SET NOCOUNT ON
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	DECLARE	 
				 @aRowCnt		INT
				,@aErrNo		INT
				,@Result		TINYINT
				,@mRank			INT
	SELECT		 
				 @aRowCnt = 0
				,@aErrNo = 0
				,@Result = 1
				,@mRank = 0

	SELECT @mRank = mRank
	FROM dbo.IGC_ChaosCastleFinal_Ranking
	WHERE mCCFType = @mCCFType AND mName = @mName

	SELECT @aErrNo = @@ERROR, @aRowCnt = @@ROWCOUNT
	IF @mCCFType = 1
	BEGIN
		IF ( @mRank > 20 OR @aRowCnt = 0)
		BEGIN
			SET @Result = 1
			SELECT @Result
			RETURN
		END
	END
	ELSE IF @mCCFType = 2
	BEGIN
		IF ( @mRank > 10 OR @aRowCnt = 0)
		BEGIN
			SET @Result = 1
			SELECT @Result
			RETURN
		END
	END

	SET @Result = 0
	SELECT @Result
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_SetDSFReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_SetDSFReward]
	@CharName varchar(10),
	@Stage tinyint,
	@RewardType tinyint
AS
BEGIN
	SET NOCOUNT ON;

	INSERT INTO [BattleCore].[dbo].BattleCore_DevilSquareFinal_Reward (CharName, Stage, RewardType, RewardGain, RewardDate) VALUES (@CharName, @Stage, @RewardType, 0, GETDATE())
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_SetDSFGainReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_SetDSFGainReward]
	@AccountID varchar(10),
	@Name varchar(10),
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode)
	BEGIN
		SELECT 0 AS Result
		RETURN
	END

	DECLARE @KeyName varchar(10)
	SELECT @KeyName = Name FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode

	UPDATE [BattleCore].[dbo].BattleCore_DevilSquareFinal_Reward SET RewardGain = 1 WHERE CharName = @KeyName
	SELECT 1 AS Result
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_SetCCReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_SetCCReward]
	@CharName varchar(10),
	@RewardType tinyint
AS
BEGIN
	SET NOCOUNT ON;

	INSERT INTO [BattleCore].[dbo].BattleCore_ChaosCastle_Reward(CharName, RewardType, RewardGain, RewardDate) VALUES (@CharName, @RewardType, 0, GETDATE())
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_SetCCGainReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_SetCCGainReward]
	@AccountID varchar(10),
	@Name varchar(10),
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode)
	BEGIN
		SELECT 0 AS Result
		RETURN
	END

	DECLARE @KeyName varchar(10)
	SELECT @KeyName = Name FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode

	UPDATE [BattleCore].[dbo].BattleCore_ChaosCastle_Reward SET RewardGain = 1 WHERE CharName = @KeyName
	SELECT 1 AS Result
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_SetCCFReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_SetCCFReward]
	@CharName varchar(10),
	@Stage tinyint,
	@RewardType tinyint
AS
BEGIN
	SET NOCOUNT ON;

	INSERT INTO [BattleCore].[dbo].BattleCore_ChaosCastleFinal_Reward (CharName, Stage, RewardType, RewardGain, RewardDate) VALUES (@CharName, @Stage, @RewardType, 0, GETDATE())
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_SetCCFGainReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_SetCCFGainReward]
	@AccountID varchar(10),
	@Name varchar(10),
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode)
	BEGIN
		SELECT 0 AS Result
		RETURN
	END

	DECLARE @KeyName varchar(10)
	SELECT @KeyName = Name FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode

	UPDATE [BattleCore].[dbo].BattleCore_ChaosCastleFinal_Reward SET RewardGain = 1 WHERE CharName = @KeyName
	SELECT 1 AS Result
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_SavePetItemInfo]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_SavePetItemInfo]
	@ItemSerial bigint,
	@ServerCode int,
	@PetLevel int,
	@PetExp int
AS
BEGIN
	SET NOCOUNT ON;

    UPDATE BattleCore_PetItem_Info SET Pet_Level = @PetLevel, Pet_Exp = @PetExp
	WHERE ItemSerial = @ItemSerial AND ServerCode = @ServerCode
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_SaveCCKillPoint]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_SaveCCKillPoint]
	@CharacterName varchar(10),
	@Point int,
	@CastleIndex int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCore_ChaosCastle_KillPoint WHERE Name = @CharacterName AND CastleIndex = @CastleIndex)
	BEGIN
		INSERT INTO [BattleCore].[dbo].BattleCore_ChaosCastle_KillPoint (Name, KillPoint, CastleIndex) VALUES (@CharacterName, @Point, @CastleIndex)
	END
	ELSE
	BEGIN
		UPDATE [BattleCore].[dbo].BattleCore_ChaosCastle_KillPoint SET KillPoint = KillPoint + @Point WHERE Name = @CharacterName AND CastleIndex = @CastleIndex
	END
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_LoadPetItemInfo]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_LoadPetItemInfo]
	@ItemSerial bigint,
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

    SELECT Pet_Level, Pet_Exp FROM BattleCore_PetItem_Info WHERE ItemSerial = @ItemSerial AND ServerCode = @ServerCode
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_JoinUser]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_JoinUser]
	@AccountID varchar(10),
	@Name varchar(10),
	@UBFName varchar(10),
	@ServerCode int,
	@RegisterState int,
	@RegisterMonth int,
	@RegisterDay int
AS
BEGIN
	SET NOCOUNT ON;

	IF ((SELECT COUNT (*) FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND RegisterState = 1) >= 2)
	BEGIN
		SELECT 4 AS Result
		RETURN
	END

	IF EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @UBFName AND ServerCode = @ServerCode AND RegisterState = 1)
	BEGIN
		SELECT 2 AS Result
		RETURN
	END

	IF EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @UBFName AND ServerCode = @ServerCode AND RegisterState = 0)
	BEGIN
		DECLARE @LeftTime smalldatetime
		SELECT @LeftTime = LeftTime FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @UBFName AND ServerCode = @ServerCode AND RegisterState = 0

		IF (DATEDIFF(SECOND, @LeftTime, GETDATE()) < 180)
		BEGIN
			SELECT 3 AS Result, (180 - DATEDIFF(SECOND, @LeftTime, GETDATE())) AS LeftSecond
			RETURN
		END
		ELSE
		BEGIN
			UPDATE [BattleCore].[dbo].BattleCoreInfo SET RegisterState = 1, RegisterMonth = @RegisterMonth, RegisterDay = @RegisterDay WHERE AccountID = @AccountID AND UBFName = @UBFName AND ServerCode = @ServerCode
			SELECT 1 AS Result
			RETURN
		END
	END
	ELSE
	BEGIN

		DECLARE @FreeKeyName int
		SET @FreeKeyName = 0

		WHILE (1 = 1)
		BEGIN
			SET @FreeKeyName = ROUND(((2000000000 - 1 -1) * RAND() + 1), 0)
			IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE Name = @FreeKeyName)
			BEGIN
				BREAK
			END
		END

		INSERT INTO [BattleCore].[dbo].BattleCoreInfo (AccountID, Name, UBFName, ServerCode, RegisterState, RegisterMonth, RegisterDay, LeftTime) VALUES
		(@AccountID, @FreeKeyName, @UBFName, @ServerCode, 1, @RegisterMonth, @RegisterDay, NULL)

		INSERT INTO [BattleCore].[dbo].AccountCharacter (Id, GameID1, GameID2, GameID3, GameID4, GameID5, GameIDC, MoveCnt, WarehouseExpansion, SecCode) VALUES
		(@AccountID, NULL, NULL, NULL, NULL, NULL, NULL, 0, 1, 0)

		SELECT 0 AS Result
	END
		RETURN


END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_GetUserInfo]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_GetUserInfo]
	@AccountID varchar(10),
	@Name varchar(10),
	@ServerCode int,
	@IsUBFServer int
AS
BEGIN
	SET NOCOUNT ON;

	IF (@IsUBFServer = 1) -- Battle Core GS
	BEGIN
		IF EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND Name = @Name)
		BEGIN
			SELECT 1 AS Result, RegisterState, RegisterMonth, RegisterDay FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND Name = @Name
			RETURN
		END
		ELSE
		BEGIN
			SELECT 0 AS Result
			RETURN
		END
	END
	ELSE IF (@IsUBFServer = 0) -- Normal GS
	BEGIN
		IF EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode)
		BEGIN
			SELECT 1 AS Result, RegisterState, RegisterMonth, RegisterDay FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode
			RETURN
		END
		ELSE
		BEGIN
			SELECT 0 AS Result
			RETURN
		END
	END
	ELSE
	BEGIN
		SELECT 0 AS Result
		RETURN
	END			
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_GetRealName]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_GetRealName]
	@KeyName varchar(10)
AS
BEGIN
	SET NOCOUNT ON;

	SELECT UBFName AS RealName, ServerCode FROM [BattleCore].[dbo].BattleCoreInfo WHERE Name = @KeyName
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_GetDSFReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_GetDSFReward]
	@AccountID varchar(10),
	@Name varchar(10),
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode)
	BEGIN
		SELECT 2 AS Result
		RETURN
	END

	DECLARE @KeyName varchar(10)
	SELECT @KeyName = Name FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode

	SELECT 1 AS Result, * FROM [BattleCore].[dbo].BattleCore_DevilSquareFinal_Reward WHERE CharName = @KeyName
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_GetCCReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_GetCCReward]
	@AccountID varchar(10),
	@Name varchar(10),
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode)
	BEGIN
		SELECT 2 AS Result
		RETURN
	END

	DECLARE @KeyName varchar(10)
	SELECT @KeyName = Name FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode

	SELECT 1 AS Result, * FROM [BattleCore].[dbo].BattleCore_ChaosCastle_Reward WHERE CharName = @KeyName
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_GetCCFReward]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_GetCCFReward]
	@AccountID varchar(10),
	@Name varchar(10),
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode)
	BEGIN
		SELECT 2 AS Result
		RETURN
	END

	DECLARE @KeyName varchar(10)
	SELECT @KeyName = Name FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode

	SELECT 1 AS Result, * FROM [BattleCore].[dbo].BattleCore_ChaosCastleFinal_Reward WHERE CharName = @KeyName
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_DeleteCharacter]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_DeleteCharacter]
	@AccountID varchar(10),
	@Name varchar(10),
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

	IF NOT EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode)
	BEGIN
		SELECT 0 AS Result
		RETURN
	END

	DECLARE @KeyName varchar(10)
	SELECT @KeyName = Name FROM [BattleCore].[dbo].BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @Name AND ServerCode = @ServerCode

	DELETE FROM [BattleCore].[dbo].Character WHERE AccountID = @AccountID AND Name = @KeyName
	DELETE FROM [BattleCore].[dbo].IGC_PeriodBuffInfo WHERE CharacterName = @KeyName
	DELETE FROM [BattleCore].[dbo].IGC_PeriodItemInfo WHERE CharacterName = @KeyName
	DELETE FROM [BattleCore].[dbo].OptionData WHERE Name = @KeyName
	DELETE FROM [BattleCore].[dbo].PetWarehouse WHERE Name = @KeyName
	DELETE FROM [BattleCore].[dbo].T_Event_Inventory WHERE Name = @KeyName
	DELETE FROM [BattleCore].[dbo].T_PentagramInfo WHERE Name = @KeyName
	DELETE FROM [BattleCore].[dbo].T_LUCKY_ITEM_INFO WHERE CharName = @KeyName

	SELECT 1 AS Result
END
GO
/****** Object:  StoredProcedure [dbo].[IGC_BattleCore_CopyPetItemInfo]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[IGC_BattleCore_CopyPetItemInfo]
	@PetItemSerial bigint,
	@ServerCode int
AS
BEGIN
	SET NOCOUNT ON;

	DECLARE @ItemSerial bigint, @Pet_Level smallint, @Pet_Exp int
	SELECT @ItemSerial = ItemSerial, @Pet_Level = Pet_Level, @Pet_Exp = Pet_Exp FROM T_PetItem_Info WHERE ItemSerial = @PetItemSerial

	IF EXISTS (SELECT * FROM [BattleCore].[dbo].BattleCore_PetItem_Info WHERE ItemSerial = @ItemSerial AND ServerCode = @ServerCode)
	BEGIN
		DELETE FROM [BattleCore].[dbo].BattleCore_PetItem_Info WHERE ItemSerial = @ItemSerial AND ServerCode = @ServerCode
	END

	INSERT INTO [BattleCore].[dbo].BattleCore_PetItem_Info (ItemSerial, ServerCode, Pet_Level, Pet_Exp) VALUES (@PetItemSerial, @ServerCode, @Pet_Level, @Pet_Exp)
END
GO

/****** Object:  StoredProcedure [dbo].[IGC_ArcaBattleProcInsert]    Script Date: 02/21/2019 16:53:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  procedure [dbo].[IGC_ArcaBattleProcInsert]
 @nProcState tinyint
as     
BEGIN  

 DECLARE @return int
 SET @return = 0  
 Set  nocount on

IF NOT EXISTS ( SELECT Proc_State FROM IGC_ARCA_BATTLE_PROC_STATE WITH ( READUNCOMMITTED ) )  
  BEGIN
   begin transaction      
  INSERT INTO IGC_ARCA_BATTLE_PROC_STATE (Proc_State) VALUES  ( @nProcState )
   END
ELSE
 begin transaction      
  UPDATE IGC_ARCA_BATTLE_PROC_STATE SET  Proc_State = @nProcState

IF ( @@Error  <> 0 )
 BEGIN	
	rollback transaction
	SET @return = -1
	SELECT @return
 END 
ELSE
 BEGIN
	commit transaction
	SELECT @return
 END
END
GO


/****** Object:  StoredProcedure [dbo].[WZ_EventMapEnterCount_Get]    Script Date: 03/03/2019 00:32:14 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/******************************************************************************
**	Name : WZ_EventMapEnterCount_Get
**	Desc : ???? ???? ?? ?? ??

**	Exec : WZ_EventMapEnterCount_Get '???'

**	Auth : ? ? ?
**	Date : 2015-01-29
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:				Description:
**	--------	--------			---------------------------------------
*******************************************************************************/
CREATE PROCEDURE [dbo].[WZ_EventMapEnterCount_Get]
	@szCharacterName	VARCHAR(10)	
AS
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

DECLARE @LastDate SMALLDATETIME

IF NOT EXISTS ( SELECT * FROM dbo.T_EventMapEnterLimit
				WHERE CharacterName = @szCharacterName )
BEGIN
	INSERT INTO dbo.T_EventMapEnterLimit (CharacterName)
	VALUES (@szCharacterName)
END

SELECT @LastDate = LastDate
FROM dbo.T_EventMapEnterLimit
WHERE CharacterName = @szCharacterName

IF (CONVERT(INT,CONVERT(CHAR(8),@LastDate,112)) < CONVERT(INT,CONVERT(CHAR(8),GETDATE(),112)))
BEGIN
	SELECT 0, 0, 0, 0, 0, 0
END
ELSE
	SELECT
		BloodCastle
		,ChaosCastle	
		,DevilSquare
		,DoppelGanger	
		,ImperialGuardian
		,IllusionTempleRenewal
	FROM dbo.T_EventMapEnterLimit
	WHERE CharacterName = @szCharacterName

GO


INSERT [dbo].[DefaultClassType] ([Class], [Strength], [Dexterity], [Vitality], [Energy], [MagicList], [Life], [MaxLife], [Mana], [MaxMana], [MapNumber], [MapPosX], [MapPosY], [Quest], [DbVersion], [Leadership], [Level], [LevelUpPoint], [Inventory], [LevelLife], [LevelMana], [VitalityToLife], [EnergyToMana]) VALUES (0, 18, 18, 15, 30, 0xFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000, 60, 60, 60, 60, 0, 182, 128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 3, 0, 1, 0, [encoded data, 15170 characters], 1, 2, 1, 2)
GO
INSERT [dbo].[DefaultClassType] ([Class], [Strength], [Dexterity], [Vitality], [Energy], [MagicList], [Life], [MaxLife], [Mana], [MaxMana], [MapNumber], [MapPosX], [MapPosY], [Quest], [DbVersion], [Leadership], [Level], [LevelUpPoint], [Inventory], [LevelLife], [LevelMana], [VitalityToLife], [EnergyToMana]) VALUES (16, 28, 20, 25, 10, 0xFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000, 110, 110, 20, 20, 0, 182, 128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 3, 0, 1, 0, [encoded data, 15170 characters], 2, 0.5, 3, 1)
GO
INSERT [dbo].[DefaultClassType] ([Class], [Strength], [Dexterity], [Vitality], [Energy], [MagicList], [Life], [MaxLife], [Mana], [MaxMana], [MapNumber], [MapPosX], [MapPosY], [Quest], [DbVersion], [Leadership], [Level], [LevelUpPoint], [Inventory], [LevelLife], [LevelMana], [VitalityToLife], [EnergyToMana]) VALUES (32, 22, 25, 20, 15, 0xFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000, 80, 80, 30, 30, 0, 182, 128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 3, 0, 1, 0, [encoded data, 15170 characters], 1, 1.5, 2, 1.5)
GO
INSERT [dbo].[DefaultClassType] ([Class], [Strength], [Dexterity], [Vitality], [Energy], [MagicList], [Life], [MaxLife], [Mana], [MaxMana], [MapNumber], [MapPosX], [MapPosY], [Quest], [DbVersion], [Leadership], [Level], [LevelUpPoint], [Inventory], [LevelLife], [LevelMana], [VitalityToLife], [EnergyToMana]) VALUES (48, 26, 26, 26, 26, 0xFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000, 110, 110, 60, 60, 0, 182, 128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 3, 0, 1, 0, [encoded data, 15170 characters], 1, 1, 2, 2)
GO
INSERT [dbo].[DefaultClassType] ([Class], [Strength], [Dexterity], [Vitality], [Energy], [MagicList], [Life], [MaxLife], [Mana], [MaxMana], [MapNumber], [MapPosX], [MapPosY], [Quest], [DbVersion], [Leadership], [Level], [LevelUpPoint], [Inventory], [LevelLife], [LevelMana], [VitalityToLife], [EnergyToMana]) VALUES (64, 26, 20, 20, 15, 0xFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000, 25, 25, 90, 90, 0, 182, 128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 3, 24, 1, 0,[encoded data, 15170 characters], 1.5, 1, 2, 1.5)
GO
INSERT [dbo].[DefaultClassType] ([Class], [Strength], [Dexterity], [Vitality], [Energy], [MagicList], [Life], [MaxLife], [Mana], [MaxMana], [MapNumber], [MapPosX], [MapPosY], [Quest], [DbVersion], [Leadership], [Level], [LevelUpPoint], [Inventory], [LevelLife], [LevelMana], [VitalityToLife], [EnergyToMana]) VALUES (80, 21, 21, 18, 23, 0xFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000, 70, 70, 40, 40, 0, 182, 128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 3, 0, 1, 0,[encoded data, 15170 characters], 1, 1.5, 2, 1.5)
GO
INSERT [dbo].[DefaultClassType] ([Class], [Strength], [Dexterity], [Vitality], [Energy], [MagicList], [Life], [MaxLife], [Mana], [MaxMana], [MapNumber], [MapPosX], [MapPosY], [Quest], [DbVersion], [Leadership], [Level], [LevelUpPoint], [Inventory], [LevelLife], [LevelMana], [VitalityToLife], [EnergyToMana]) VALUES (96, 32, 27, 25, 20, 0xFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000, 100, 100, 40, 40, 0, 182, 128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 3, 0, 1, 0, [encoded data, 15170 characters], 1.3, 1, 2, 1.3)
GO
INSERT [dbo].[DefaultClassType] ([Class], [Strength], [Dexterity], [Vitality], [Energy], [MagicList], [Life], [MaxLife], [Mana], [MaxMana], [MapNumber], [MapPosX], [MapPosY], [Quest], [DbVersion], [Leadership], [Level], [LevelUpPoint], [Inventory], [LevelLife], [LevelMana], [VitalityToLife], [EnergyToMana]) VALUES (112, 30, 30, 25, 24, 0xFF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000, 110, 110, 40, 40, 0, 182, 128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 3, 0, 1, 0, [encoded data, 15170 characters], 2, 1, 2, 1)
GO

/****** Object:  Default [DF__AccountCh__MoveC__7A3223E8]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[AccountCharacter] ADD  CONSTRAINT [DF__AccountCh__MoveC__7A3223E8]  DEFAULT ((0)) FOR [MoveCnt]
GO
/****** Object:  Default [DF_AccountCharacter_WarehouseExpansion]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[AccountCharacter] ADD  CONSTRAINT [DF_AccountCharacter_WarehouseExpansion]  DEFAULT ((0)) FOR [WarehouseExpansion]
GO
/****** Object:  Default [DF__AccountCharacter__SecCode]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[AccountCharacter] ADD  DEFAULT ((0)) FOR [SecCode]
GO
/****** Object:  Default [DF__AccountCharacter__ExtClass]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[AccountCharacter] ADD  DEFAULT ((0)) FOR [ExtClass]
GO
/****** Object:  Default [DF_T_Pet_Info_Pet_Level]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[BattleCore_PetItem_Info] ADD  CONSTRAINT [DF_T_Pet_Info_Pet_Level]  DEFAULT ((0)) FOR [Pet_Level]
GO
/****** Object:  Default [DF_T_Pet_Info_Pet_Exp]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[BattleCore_PetItem_Info] ADD  CONSTRAINT [DF_T_Pet_Info_Pet_Exp]  DEFAULT ((0)) FOR [Pet_Exp]
GO
/****** Object:  Default [DF_BattleCoreInfo_Observer]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[BattleCoreInfo] ADD  CONSTRAINT [DF_BattleCoreInfo_Observer]  DEFAULT ((0)) FOR [Observer]
GO
/****** Object:  Default [DF_Character_cLevel]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_cLevel]  DEFAULT ((1)) FOR [cLevel]
GO
/****** Object:  Default [DF_Character_LevelUpPoint]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_LevelUpPoint]  DEFAULT ((0)) FOR [LevelUpPoint]
GO
/****** Object:  Default [DF_Character_Experience]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_Experience]  DEFAULT ((0)) FOR [Experience]
GO
/****** Object:  Default [DF_Character_Money]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_Money]  DEFAULT ((0)) FOR [Money]
GO
/****** Object:  Default [DF_Character_MapDir]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_MapDir]  DEFAULT ((0)) FOR [MapDir]
GO
/****** Object:  Default [DF_Character_PkCount]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_PkCount]  DEFAULT ((0)) FOR [PkCount]
GO
/****** Object:  Default [DF_Character_PkLevel]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_PkLevel]  DEFAULT ((3)) FOR [PkLevel]
GO
/****** Object:  Default [DF_Character_PkTime]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_PkTime]  DEFAULT ((0)) FOR [PkTime]
GO
/****** Object:  Default [DF_Character_CtlCode]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_CtlCode]  DEFAULT ((0)) FOR [CtlCode]
GO
/****** Object:  Default [DF__Character__Quest__40F9A68C]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF__Character__Quest__40F9A68C]  DEFAULT ((0)) FOR [Quest]
GO
/****** Object:  Default [DF__Character__ChatL__6754599E]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  DEFAULT ((0)) FOR [ChatLimitTime]
GO
/****** Object:  Default [DF_Character_RESETS]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_RESETS]  DEFAULT ((0)) FOR [RESETS]
GO
/****** Object:  Default [DF_Character_Married]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_Married]  DEFAULT ((0)) FOR [Married]
GO
/****** Object:  Default [DF__Character__mLeve__6A30C649]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  DEFAULT ((0)) FOR [mLevel]
GO
/****** Object:  Default [DF__Character__mlPoi__6B24EA82]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  DEFAULT ((0)) FOR [mlPoint]
GO
/****** Object:  Default [DF__Character__mlExp__6C190EBB]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  DEFAULT ((0)) FOR [mlExperience]
GO
/****** Object:  Default [DF__Character__mlNex__6D0D32F4]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  DEFAULT ((0)) FOR [mlNextExp]
GO
/****** Object:  Default [DF_Character_InventoryExpansion]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_InventoryExpansion]  DEFAULT ((0)) FOR [InventoryExpansion]
GO
/****** Object:  Default [DF_Character_WinDuels]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_WinDuels]  DEFAULT ((0)) FOR [WinDuels]
GO
/****** Object:  Default [DF_Character_LoseDuels]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_LoseDuels]  DEFAULT ((0)) FOR [LoseDuels]
GO
/****** Object:  Default [DF__Character__Penal__70DDC3D8]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  DEFAULT ((0)) FOR [PenaltyMask]
GO
/****** Object:  Default [DF__Character__Block__71D1E811]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  DEFAULT ((0)) FOR [BlockChatTime]
GO
/****** Object:  Default [DF_Character_FruitAddPoint]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_FruitAddPoint]  DEFAULT ((0)) FOR [FruitAddPoint]
GO
/****** Object:  Default [DF_Character_FruitSubPoint]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_FruitSubPoint]  DEFAULT ((0)) FOR [FruitSubPoint]
GO
/****** Object:  Default [DF_Character_GRANRESET]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_GRANRESET]  DEFAULT ((0)) FOR [GRANDRESET]
GO
/****** Object:  Default [DF_Character_GRBonusSTR]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_GRBonusSTR]  DEFAULT ((0)) FOR [GRBonusSTR]
GO
/****** Object:  Default [DF_Character_GRBonusAGI]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_GRBonusAGI]  DEFAULT ((0)) FOR [GRBonusAGI]
GO
/****** Object:  Default [DF_Character_GRBonusHP]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_GRBonusHP]  DEFAULT ((0)) FOR [GRBonusVIT]
GO
/****** Object:  Default [DF_Character_GRBonusMP]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_GRBonusMP]  DEFAULT ((0)) FOR [GRBonusENE]
GO
/****** Object:  Default [DF_Character_GRBonusCMD]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_GRBonusCMD]  DEFAULT ((0)) FOR [GRBonusCMD]
GO
/****** Object:  Default [DF_Character_CustomQuestOn]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_CustomQuestOn]  DEFAULT ((0)) FOR [CustomQuestOn]
GO
/****** Object:  Default [DF_Character_GiftItem]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_GiftItem]  DEFAULT ((0)) FOR [GiftItem]
GO
/****** Object:  Default [DF_Character_HuntingUserOpen]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[Character] ADD  CONSTRAINT [DF_Character_HuntingUserOpen]  DEFAULT ((0)) FOR [HuntingUserOpen]
GO
/****** Object:  Default [DF__CustomQue__Quest__208CD6FA]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[CustomQuest] ADD  DEFAULT ((0)) FOR [Quest]
GO
/****** Object:  Default [DF_GameServerInfo_Number]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[GameServerInfo] ADD  CONSTRAINT [DF_GameServerInfo_Number]  DEFAULT ((0)) FOR [Number]
GO
/****** Object:  Default [DF_GameServerInfo_ZenCount]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[GameServerInfo] ADD  CONSTRAINT [DF_GameServerInfo_ZenCount]  DEFAULT ((0)) FOR [ZenCount]
GO
/****** Object:  Default [DF__GameServe__GensR__7C4F7684]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[GameServerInfo] ADD  DEFAULT ((1)) FOR [GensRankingMonth]
GO
/****** Object:  Default [DF__IGC_Chaos__mChar__7D439ABD]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[IGC_ChaosCastleFinal_Scores] ADD  DEFAULT ((0)) FOR [mCharLevel]
GO
/****** Object:  Default [DF__IGC_Chaos__mChar__7E37BEF6]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[IGC_ChaosCastleFinal_Scores] ADD  DEFAULT ((0)) FOR [mCharExperience]
GO
/****** Object:  Default [DF__IGC_Chaos__mChar__7F2BE32F]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[IGC_ChaosCastleFinal_Scores] ADD  DEFAULT ((0)) FOR [mCharClass]
GO
/****** Object:  Default [DF__IGC_Perio__SetEx__00200768]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[IGC_PeriodItemInfo] ADD  DEFAULT ((0)) FOR [SetExpire]
GO
/****** Object:  Default [DF__OptionDat__ChatW__4A8310C6]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[OptionData] ADD  CONSTRAINT [DF__OptionDat__ChatW__4A8310C6]  DEFAULT ((255)) FOR [ChatWindow]
GO
/****** Object:  Default [DF__OptionDat__Enabl__02084FDA]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[OptionData] ADD  DEFAULT ((0)) FOR [EnableChangeMode]
GO
/****** Object:  Default [DF__OptionDat__PlayG__02FC7413]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[OptionData] ADD  DEFAULT ((0)) FOR [PlayGuideLvL]
GO
/****** Object:  Default [DF__OptionDat__PlayG__03F0984C]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[OptionData] ADD  DEFAULT ((0)) FOR [PlayGuideCheck]
GO
/****** Object:  Default [DF__QUEST_PLA__Quest__2EDAF651]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [QuestID]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__2FCF1A8A]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterID1]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__30C33EC3]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterKillCount1]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__31B762FC]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterID2]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__32AB8735]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterKillCount2]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__339FAB6E]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterID3]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__3493CFA7]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterKillCount3]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__3587F3E0]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterID4]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__367C1819]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterKillCount4]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__37703C52]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterID5]
GO
/****** Object:  Default [DF__QUEST_PLA__Monst__3864608B]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[QUEST_PLAYER_INFO] ADD  DEFAULT ((-1)) FOR [MonsterKillCount5]
GO
/****** Object:  Default [DF_T_GMSystem_AuthorityMask]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_GMSystem] ADD  CONSTRAINT [DF_T_GMSystem_AuthorityMask]  DEFAULT ((0)) FOR [AuthorityMask]
GO
/****** Object:  Default [DF_T_PentagramInfo_JewelIndex]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_JewelIndex]  DEFAULT ((255)) FOR [JewelIndex]
GO
/****** Object:  Default [DF_T_PentagramInfo_ItemType]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_ItemType]  DEFAULT ((255)) FOR [ItemType]
GO
/****** Object:  Default [DF_T_PentagramInfo_ItemIndex]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_ItemIndex]  DEFAULT ((511)) FOR [ItemIndex]
GO
/****** Object:  Default [DF_T_PentagramInfo_MainAttribute]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_MainAttribute]  DEFAULT ((255)) FOR [MainAttribute]
GO
/****** Object:  Default [DF_T_PentagramInfo_Rank1]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_Rank1]  DEFAULT ((255)) FOR [Rank1]
GO
/****** Object:  Default [DF_T_PentagramInfo_Rank2]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_Rank2]  DEFAULT ((255)) FOR [Rank2]
GO
/****** Object:  Default [DF_T_PentagramInfo_Rank3]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_Rank3]  DEFAULT ((255)) FOR [Rank3]
GO
/****** Object:  Default [DF_T_PentagramInfo_Rank4]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_Rank4]  DEFAULT ((255)) FOR [Rank4]
GO
/****** Object:  Default [DF_T_PentagramInfo_Rank5]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_Rank5]  DEFAULT ((255)) FOR [Rank5]
GO
/****** Object:  Default [DF_T_PentagramInfo_RegDate]    Script Date: 02/21/2019 16:53:48 ******/
ALTER TABLE [dbo].[T_PentagramInfo] ADD  CONSTRAINT [DF_T_PentagramInfo_RegDate]  DEFAULT (getdate()) FOR [RegDate]
GO


ALTER TABLE [dbo].[T_EventMapEnterLimit] ADD  CONSTRAINT [DF_T_EventMapEnterLimit_BloodCastle]  DEFAULT ((0)) FOR [BloodCastle]
GO

ALTER TABLE [dbo].[T_EventMapEnterLimit] ADD  CONSTRAINT [DF_T_EventMapEnterLimit_ChaosCastle]  DEFAULT ((0)) FOR [ChaosCastle]
GO

ALTER TABLE [dbo].[T_EventMapEnterLimit] ADD  CONSTRAINT [DF_T_EventMapEnterLimit_DevilSquare]  DEFAULT ((0)) FOR [DevilSquare]
GO

ALTER TABLE [dbo].[T_EventMapEnterLimit] ADD  CONSTRAINT [DF_T_EventMapEnterLimit_DoppelGanger]  DEFAULT ((0)) FOR [DoppelGanger]
GO

ALTER TABLE [dbo].[T_EventMapEnterLimit] ADD  CONSTRAINT [DF_T_EventMapEnterLimit_ImperialGuardian_Weekdays]  DEFAULT ((0)) FOR [ImperialGuardian]
GO

ALTER TABLE [dbo].[T_EventMapEnterLimit] ADD  CONSTRAINT [DF_T_EventMapEnterLimit_IllusionTempleRenewal]  DEFAULT ((0)) FOR [IllusionTempleRenewal]
GO

ALTER TABLE [dbo].[T_EventMapEnterLimit] ADD  CONSTRAINT [DF_T_EventMapEnterLimit_LastDate]  DEFAULT (getdate()) FOR [LastDate]
GO