ALTER TABLE [TblCampInfo] ADD [tnSiegeCount] [tinyint] NULL
GO

ALTER TABLE [TblCampShopInfo] DROP COLUMN [TransferTime]
GO

DROP TABLE [TblCastleInfo]
GO

CREATE TABLE [TblCastleInfo] (
	[nCastleID] [int] IDENTITY (1, 1) NOT NULL,
	[nGuildID] [int] NULL,
	[tnZone] [tinyint] NULL,
	[tnChannel] [tinyint] NULL,
	[tnName] [tinyint] NULL,
	[tnSiegeCount] [tinyint] NULL,
	[tnInvincibleCount] [tinyint] NULL,
	[snTotalSiegeCount] [smallint] NULL,
	[nTotalTaxMoney] [int] NULL,
	[bRight] [varbinary] (10) NULL,
	[fPosInX] [real] NULL,
	[fPosInY] [real] NULL,
	[fPosInZ] [real] NULL,
	[fPosOutX] [real] NULL,
	[fPosOutY] [real] NULL,
	[fPosOutZ] [real] NULL,
	[snItemID] [smallint] NULL,
	[tnItemNum] [tinyint] NULL
) ON [PRIMARY]
GO

CREATE TABLE [TblCastleTaxInfo] (
	[nCastleID] [int] NULL,
	[tnType] [tinyint] NULL,
	[tnTax] [tinyint] NULL,
	[nTempMoney] [int] NULL,
	[nTaxMoney] [int] NULL,
	[tnTaxChangable] [tinyint] NULL
) ON [PRIMARY]
GO
	
CREATE TABLE [TblCastleMineralInfo] (
	[nCastleID] [int] NULL ,
	[snMineralID] [smallint] NULL ,
	[snAmount] [smallint] NULL ,
	[tnFlag] [tinyint] NULL 
) ON [PRIMARY]
GO


DROP PROC USPCastleUpdate
GO


SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO


CREATE PROC USPCastleUpdate @nCastleID INT,@nGuildID INT,@tnSiegeCount TINYINT,
	@tnInvincibleCount TINYINT,@snTotalSiegeCount SMALLINT,@nTotalTaxMoney INT,
	@snItemID SMALLINT,@tnItemNum TINYINT
AS
	SET NOCOUNT ON

	DECLARE @RETURN INT

	UPDATE TblCastleInfo
	SET nGuildID = @nGuildID,tnSiegeCount = @tnSiegeCount,tnInvincibleCount = @tnInvincibleCount,
		snTotalSiegeCount = @snTotalSiegeCount,nTotalTaxMoney = @nTotalTaxMoney,
		snItemID = @snItemID,tnItemNum = @tnItemNum
	WHERE nCastleID = @nCastleID
	
	SET @RETURN = @@ROWCOUNT

	SELECT @RETURN



GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

