SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_MEMBER]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_MEMBER](
	[IDX] [int] IDENTITY(10000,1) NOT NULL,
	[REGISTER_DATE] [datetime] NOT NULL CONSTRAINT [DF_TB_MEMBER_REGISTER_DATE]  DEFAULT (getdate()),
	[LAST_DATE] [datetime] NOT NULL CONSTRAINT [DF_TB_MEMBER_LAST_DATE]  DEFAULT (getdate()),
	[LOGINID] [varchar](16) NOT NULL,
	[PASSWORD] [varbinary](100) NOT NULL,
	[LAST_SERVER_NUM] [int] NOT NULL CONSTRAINT [DF_TB_MEMBER_LAST_SERVER_NUM]  DEFAULT ((0)),
	[LAST_CHANNEL_NUM] [int] NOT NULL CONSTRAINT [DF_TB_MEMBER_LAST_CHANNEL_NUM]  DEFAULT ((0)),
	[SLEVEL] [tinyint] NOT NULL CONSTRAINT [DF_TB_MEMBER_CLASS]  DEFAULT ((0)),
 CONSTRAINT [PK_TB_MEMBER] PRIMARY KEY CLUSTERED 
(
	[IDX] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'고유번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MEMBER', @level2type=N'COLUMN', @level2name=N'IDX'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'등록일' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MEMBER', @level2type=N'COLUMN', @level2name=N'REGISTER_DATE'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'마지막 접속일' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MEMBER', @level2type=N'COLUMN', @level2name=N'LAST_DATE'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'사용자계정(ID)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MEMBER', @level2type=N'COLUMN', @level2name=N'LOGINID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'암호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MEMBER', @level2type=N'COLUMN', @level2name=N'PASSWORD'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'마지막 접속한 서버번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MEMBER', @level2type=N'COLUMN', @level2name=N'LAST_SERVER_NUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'마지막 접속한 채널번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MEMBER', @level2type=N'COLUMN', @level2name=N'LAST_CHANNEL_NUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'보안등급(0일반사용자,1운영자...)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MEMBER', @level2type=N'COLUMN', @level2name=N'SLEVEL'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_LOGIN]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_LOGIN](
	[IDX] [int] IDENTITY(1,1) NOT NULL,
	[MEMBER_IDX] [int] NOT NULL,
	[REGISTER_DATE] [datetime] NOT NULL CONSTRAINT [DF_TB_LOGIN_LOGIN_TIME]  DEFAULT (getdate()),
	[LAST_DATE] [datetime] NOT NULL CONSTRAINT [DF_TB_LOGIN_LAST_DATE]  DEFAULT (getdate()),
	[SERVER_NUM] [int] NOT NULL CONSTRAINT [DF_TB_LOGIN_SERVER_NUM]  DEFAULT ((0)),
	[CHANNEL_NUM] [int] NOT NULL CONSTRAINT [DF_TB_LOGIN_CHANNEL_NUM]  DEFAULT ((0)),
	[LAST_CHANNEL] [int] NOT NULL CONSTRAINT [DF_TB_LOGIN_LAST_CHANNEL]  DEFAULT ((0)),
	[CHARACTER_IDX] [int] NOT NULL CONSTRAINT [DF_TB_LOGIN_CHARACTER_IDX]  DEFAULT ((0)),
	[CHARACTER_NAME] [nvarchar](16) NULL,
	[INETNUM] [varchar](20) NOT NULL,
	[INSTANT_DUNGEON] [tinyint] NOT NULL CONSTRAINT [DF_TB_LOGIN_INSTANT_DUNGEON]  DEFAULT ((0)),
	[APPLY] [tinyint] NOT NULL CONSTRAINT [DF_TB_LOGIN_APPLY]  DEFAULT ((0)),
 CONSTRAINT [PK_TB_LOGIN] PRIMARY KEY CLUSTERED 
(
	[MEMBER_IDX] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_LOGIN]') AND name = N'IX_TB_LOGIN')
CREATE NONCLUSTERED INDEX [IX_TB_LOGIN] ON [dbo].[TB_LOGIN] 
(
	[IDX] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'고유번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'IDX'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'회원 테이블의 고유번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'MEMBER_IDX'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'등록일(로그인)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'REGISTER_DATE'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'갱신일(로그인)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'LAST_DATE'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'서버번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'SERVER_NUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'채널번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'CHANNEL_NUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'캐릭터고유번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'CHARACTER_IDX'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'캐릭터이름' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'CHARACTER_NAME'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP주소(IPv4)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'INETNUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'인던여부(0사용안함/1사용중)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'INSTANT_DUNGEON'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'사용여부(0대기중/1사용중)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_LOGIN', @level2type=N'COLUMN', @level2name=N'APPLY'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_CHANNEL]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_CHANNEL](
	[IDX] [int] IDENTITY(1,1) NOT NULL,
	[REGISTER_DATE] [datetime] NOT NULL CONSTRAINT [DF_TB_CHANNEL_REGISTER_DATE]  DEFAULT (getdate()),
	[SERVER_NUM] [int] NOT NULL CONSTRAINT [DF_TB_CHANNEL_SERVER_NUM]  DEFAULT ((0)),
	[CHANNEL_NUM] [int] NOT NULL CONSTRAINT [DF_TB_CHANNEL_CHANNEL_NUM]  DEFAULT ((0)),
	[INETNUM] [varchar](20) NOT NULL,
	[IPV4] [int] NOT NULL CONSTRAINT [DF_TB_CHANNEL_IPv4]  DEFAULT ((0)),
	[PORT] [smallint] NOT NULL CONSTRAINT [DF_TB_CHANNEL_PORT]  DEFAULT ((0)),
	[STATUS] [tinyint] NOT NULL CONSTRAINT [DF_TB_CHANNEL_STATUS]  DEFAULT ((0)),
 CONSTRAINT [PK_TB_CHANNEL] PRIMARY KEY CLUSTERED 
(
	[IDX] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'고유번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_CHANNEL', @level2type=N'COLUMN', @level2name=N'IDX'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'등록일' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_CHANNEL', @level2type=N'COLUMN', @level2name=N'REGISTER_DATE'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'서버번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_CHANNEL', @level2type=N'COLUMN', @level2name=N'SERVER_NUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'채널번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_CHANNEL', @level2type=N'COLUMN', @level2name=N'CHANNEL_NUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP주소(IPv4)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_CHANNEL', @level2type=N'COLUMN', @level2name=N'INETNUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'IP주소(IPv4)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_CHANNEL', @level2type=N'COLUMN', @level2name=N'IPV4'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'상태 (0준비/1원활/2보통/3혼잡)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_CHANNEL', @level2type=N'COLUMN', @level2name=N'STATUS'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_SERVERDOWN]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'

/**********************************************************************
 *<
	FILE: GP_SERVERDOWN.SQL

	DESCRIPTION: 게임서버 다운

	CREATED BY: 곽철중

	HISTORY: Created	01/17/07	SQLServer2000
			 Modified	02/26/07	SQLServer2005

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_SERVERDOWN]
	(@SERVER_NUM	[int],	--서버번호
	 @CHANNEL_NUM	[int])	--채널번호

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

DELETE [dbo].[TB_CHANNEL]
 WHERE [SERVER_NUM]=@SERVER_NUM
   AND [CHANNEL_NUM]=@CHANNEL_NUM

DELETE [dbo].[TB_LOGIN] 
 WHERE [SERVER_NUM]=@SERVER_NUM
   AND [CHANNEL_NUM]=@CHANNEL_NUM

' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_SERVER]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_SERVER](
	[IDX] [int] IDENTITY(1,1) NOT NULL,
	[REGISTER_DATE] [datetime] NOT NULL CONSTRAINT [DF_TB_SERVER_REGISTER_DATE]  DEFAULT (getdate()),
	[NAME] [nvarchar](50) NOT NULL,
	[DESCRIPTION] [nvarchar](200) NULL,
	[STATUS] [tinyint] NOT NULL CONSTRAINT [DF_TB_SERVER_STATUS]  DEFAULT ((0)),
	[APPLY] [tinyint] NOT NULL CONSTRAINT [DF_TB_SERVER_APPLY]  DEFAULT ((0)),
 CONSTRAINT [PK_TB_SERVER] PRIMARY KEY CLUSTERED 
(
	[IDX] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'고유번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_SERVER', @level2type=N'COLUMN', @level2name=N'IDX'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'등록일' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_SERVER', @level2type=N'COLUMN', @level2name=N'REGISTER_DATE'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'서버이름' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_SERVER', @level2type=N'COLUMN', @level2name=N'NAME'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'설명' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_SERVER', @level2type=N'COLUMN', @level2name=N'DESCRIPTION'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'상태 (0준비/1원활/2보통/3혼잡)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_SERVER', @level2type=N'COLUMN', @level2name=N'STATUS'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'적용여부 (0 사용중, 1 사용중지)' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_SERVER', @level2type=N'COLUMN', @level2name=N'APPLY'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_CONCURRENT_USER]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
/**********************************************************************
 *<
	FILE: GP_CONCURRENT_USER.SQL

	DESCRIPTION:

	CREATED BY:

	HISTORY:

 *>	Copyright (c) 2008, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_CONCURRENT_USER]
	(@SERVER_IDX	[int],			--서버번호
	 @VALUE			[int]OUTPUT)	--반환값

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

SELECT @VALUE=COUNT(IDX)
  FROM [dbo].[TB_LOGIN]
 WHERE [SERVER_NUM]=@SERVER_IDX
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_MEMBER_CHECK]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
/**********************************************************************
 *<
	FILE: GP_MEMBER_CHECK.SQL

	DESCRIPTION: 로그 체크

	CREATED BY: 곽철중

	HISTORY: Created	01/18/07	SQLServer2000
			 Modified	02/26/07	SQLServer2005

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_MEMBER_CHECK]
	(@LOGIN_IDX			[int]			-- 고유번호 - 로그 테이블
	,@MEMBER_IDX		[int]			-- 고유번호 - 회원 테이블
	,@SERVER_NUM		[int]			-- 서버번호
	,@CHANNEL_NUM		[int]			-- 채널번호
	,@LAST_CHANNEL		[int]OUTPUT		-- 이전채널
	,@CHARACTER_IDX		[int]OUTPUT		-- 고유번호 - 캐릭터 테이블
	,@INSTANT_DUNGEON	[tinyint]OUTPUT -- 인던여부
	,@SLEVEL			[tinyint]OUTPUT -- 보안등급
	,@RETVALUE			[int]OUTPUT)	-- 반환값

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

--로그인 정보검사 수정.
IF NOT EXISTS (SELECT *
				 FROM [dbo].[TB_LOGIN]
				WHERE [IDX]=@LOGIN_IDX
				  AND [MEMBER_IDX]=@MEMBER_IDX
				  AND [SERVER_NUM]=@SERVER_NUM
				  AND [CHANNEL_NUM]=@CHANNEL_NUM
				  AND [APPLY]=0)
	BEGIN
		SET @RETVALUE = 1	--체크 실패.
		RETURN
	END

--마직막 선택한 서버번호&채널번호 수정.
UPDATE [dbo].[TB_MEMBER]
   SET [LAST_SERVER_NUM]=@SERVER_NUM
	  ,[LAST_CHANNEL_NUM]=@CHANNEL_NUM
 WHERE [IDX]=@MEMBER_IDX
--오류검사 생략.

--로그인 테이블 수정.
UPDATE [dbo].[TB_LOGIN]
   SET [LAST_DATE]=GETDATE()
      ,[APPLY]=1			--0 대기중/1 사용중.
 WHERE [IDX]=@LOGIN_IDX
   AND [APPLY]=0

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	BEGIN
		SET @RETVALUE = 2	--알수없는 오류.
	END
ELSE
	BEGIN
		SELECT @LAST_CHANNEL=[LAST_CHANNEL]
			  ,@CHARACTER_IDX=[CHARACTER_IDX]
			  ,@INSTANT_DUNGEON=[INSTANT_DUNGEON]
          FROM [dbo].[TB_LOGIN]
         WHERE [IDX]=@LOGIN_IDX

		SELECT @SLEVEL=[SLEVEL]
          FROM [dbo].[TB_MEMBER]
         WHERE [IDX]=@MEMBER_IDX

		SET @RETVALUE = 0	--체크 성공.
	END



' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_MATRIX]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_MATRIX](
	[IDX] [int] IDENTITY(1,1) NOT NULL,
	[SERVER_NUM] [int] NOT NULL,
	[CHANNEL_NUM] [int] NOT NULL,
 CONSTRAINT [PK_TB_MATRIX] PRIMARY KEY CLUSTERED 
(
	[IDX] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'고유번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MATRIX', @level2type=N'COLUMN', @level2name=N'IDX'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'서버번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MATRIX', @level2type=N'COLUMN', @level2name=N'SERVER_NUM'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'채널번호' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TB_MATRIX', @level2type=N'COLUMN', @level2name=N'CHANNEL_NUM'

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_MEMBER_LOGOUT]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'

/**********************************************************************
 *<
	FILE: GP_MEMBER_LOGOUT.SQL

	DESCRIPTION: 로그아웃

	CREATED BY: 곽철중

	HISTORY: Created	01/17/07	SQLServer2000
			 Modified	02/26/07	SQLServer2005

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_MEMBER_LOGOUT]
	(@LOGIN_IDX		[int],			--고유번호 - 로그 테이블
	 @MEMBER_IDX	[int],			--고유번호 - 회원 테이블
	 @RETVALUE		[int]OUTPUT)	--반환값

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

DELETE [dbo].[TB_LOGIN]
 WHERE([IDX]=@LOGIN_IDX
   AND [MEMBER_IDX]=@MEMBER_IDX)

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	BEGIN
		SET @RETVALUE = 1 --알수없는 오류.
	END
ELSE
	BEGIN
		SET @RETVALUE = 0 --로그아웃 성공.
	END


' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_MEMBER_LOGIN]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
/**********************************************************************
 *<
	FILE: GP_MEMBER_LOGIN.SQL

	DESCRIPTION: 로그인

	CREATED BY: 곽철중

	HISTORY: Created	01/17/07	SQLServer2000
			 Modified	02/26/07	SQLServer2005

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_MEMBER_LOGIN]
	(@MEMBER_IDX		[int]OUTPUT		--고유번호 - 회원 테이블
	,@LOGON_IDX			[int]OUTPUT		--고유번호 - 로그 테이블
	,@LOGINID			[varchar](16)	--사용자 계정(ID)
	,@PASSWORD			[varchar](16)	--암호
	,@INETNUM			[varchar](20)	--IP주소(IPv4)
	,@LAST_SERVER_NUM	[int]OUTPUT		--서버번호(마지막 접속)
	,@LAST_CHANNEL_NUM	[int]OUTPUT		--채널번호(마지막 접속)
	,@SLEVEL			[tinyint]		--보안등급적용중(0일반/1운영)
	,@RETVALUE			[int]OUTPUT)	--반환값

AS

DECLARE @MEMBER_PASSWORD	[varbinary](100)
       ,@MEMBER_SLEVEL		[tinyint]

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

--계정인증

SELECT @MEMBER_IDX=[IDX]
	  ,@MEMBER_PASSWORD=[PASSWORD]
      ,@LAST_SERVER_NUM=[LAST_SERVER_NUM]
      ,@LAST_CHANNEL_NUM=[LAST_CHANNEL_NUM]
      ,@MEMBER_SLEVEL=[SLEVEL]
  FROM [dbo].[TB_MEMBER]
 WHERE [LOGINID]=@LOGINID

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	BEGIN
		SET @RETVALUE = 1	--LOGINID 오류.
		RETURN
	END
ELSE IF PWDCOMPARE( CAST(UPPER(@PASSWORD) AS varbinary(100)), @MEMBER_PASSWORD ) <> 1
	BEGIN
		SET @RETVALUE = 1	--PASSWORD 오류.
		RETURN
	END

--SLEVEL=2 BLOCK 검사

IF @MEMBER_SLEVEL = 2
	BEGIN
		SET @RETVALUE = 3	--BLOCK 적용중.
		RETURN
	END

--SLEVEL=1 보안등급검사

IF @SLEVEL = 1 AND @MEMBER_SLEVEL <> 1
	BEGIN
		SET @RETVALUE = 2	--보안등급 오류.
		RETURN
	END

--중복검사
IF EXISTS (SELECT * FROM [dbo].[TB_LOGIN] WHERE [MEMBER_IDX]=@MEMBER_IDX)
	BEGIN
		IF EXISTS (SELECT *
                     FROM [dbo].[TB_LOGIN]
                    WHERE [MEMBER_IDX]=@MEMBER_IDX
                      AND [LAST_DATE]<DATEADD(MI, -5, GETDATE())
                      AND [APPLY]=0)
			BEGIN
				DELETE [dbo].[TB_LOGIN] WHERE [MEMBER_IDX]=@MEMBER_IDX
			END
		ELSE
			BEGIN
				SET @RETVALUE = 4	--이미 서버에 접속중.
				RETURN
			END
	END

--접속일 기록
UPDATE [dbo].[TB_MEMBER]
   SET [LAST_DATE]=GETDATE()
 WHERE [IDX]=@MEMBER_IDX

--로그인 등록
INSERT [dbo].[TB_LOGIN]
      ([MEMBER_IDX]
      ,[INETNUM]
      ,[APPLY])
VALUES(@MEMBER_IDX
      ,@INETNUM
      ,1)

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	BEGIN
		SET @RETVALUE = 5	--알수없는 오류.
	END
ELSE
	BEGIN
		SELECT @LOGON_IDX=[IDX]
		  FROM [dbo].[TB_LOGIN]
		 WHERE [MEMBER_IDX]=@MEMBER_IDX

		SET @RETVALUE = 0	--로그인 성공.
	END
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_COMEIN_GAME_D]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'

/**********************************************************************
 *<
	FILE: GP_COMEIN_GAME_D.SQL

	DESCRIPTION: 멤버 업데이트

	CREATED BY: 곽철중

	HISTORY: Created	01/23/07	SQLServer2000
			 Modified	02/26/07	SQLServer2005
			 Modified	02/26/07	RENAME GP_MEMBER_UPDATE TO GP_COMEIN_GAME

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_COMEIN_GAME_D]
	(@LOGIN_IDX 		[int]					--고유번호 - 로그 테이블
	,@SERVER_NUM		[int]					--서버번호
	,@CHANNEL_NUM		[int]					--채널번호
	,@LAST_CHANNEL		[int]					--이전채널
	,@CHARACTER_IDX		[int]					--고유번호 - 캐릭터 테이블
	,@INSTANT_DUNGEON	[tinyint]				--인던여부
	,@IPV4				[int]OUTPUT	            --IPv4
	,@PORT				[smallint]OUTPUT	    --Port
	,@RETVALUE			[int]OUTPUT)			--반환값

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

SELECT @IPV4=[IPV4]
      ,@PORT=[PORT]
  FROM [dbo].[TB_CHANNEL]
 WHERE [SERVER_NUM]=@SERVER_NUM
   AND [CHANNEL_NUM]=@CHANNEL_NUM
   AND [STATUS] <> 0

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	BEGIN
		SET @RETVALUE = 1 --미등록 서버검색.
	END
ELSE
	BEGIN
		UPDATE [dbo].[TB_LOGIN] 
		   SET [LAST_DATE]=GETDATE()
              ,[SERVER_NUM]=@SERVER_NUM				--서버번호.
		 	  ,[CHANNEL_NUM]=@CHANNEL_NUM			--채널번호.
			  ,[LAST_CHANNEL]=@LAST_CHANNEL			--이전채널.
		 	  ,[CHARACTER_IDX]=@CHARACTER_IDX		--캐릭터번호.
			  ,[INSTANT_DUNGEON]=@INSTANT_DUNGEON	--0사용안함/1사용중
			  ,[APPLY]=0							--0대기중/1사용중.
		 WHERE [IDX]=@LOGIN_IDX

		IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
			BEGIN
				SET @RETVALUE = 2 --알수없는 오류.
			END
		ELSE
			BEGIN
				SET @RETVALUE = 0 --업데이트 성공.
			END
	END


' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_GAMEIN_COMPLETE]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'


/**********************************************************************
 *<
	FILE: GP_GAMEIN_COMPLETE.SQL

	DESCRIPTION:

	CREATED BY:

	HISTORY:

 *>	Copyright (c) 2009, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_GAMEIN_COMPLETE]
	(@LOGIN_IDX 		[int]					--고유번호 - 로그 테이블
	,@CHARACTER_NAME    [nvarchar](16))			--캐릭터이름

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

UPDATE [dbo].[TB_LOGIN] 
   SET [CHARACTER_NAME]=@CHARACTER_NAME		--캐릭터이름.
 WHERE [IDX]=@LOGIN_IDX

' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_MEMBER_SELECT]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'



/**********************************************************************
 *<
	FILE: GP_MEMBER_SELECT.SQL

	DESCRIPTION:

	CREATED BY:

	HISTORY:

 *>	Copyright (c) 2009, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_MEMBER_SELECT]
	(@CHARACTER_NAME    [nvarchar](16)			--캐릭터이름
	,@CHANNEL_NUM		[int]OUTPUT)				--접속한 채널번호

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

SELECT @CHANNEL_NUM=[CHANNEL_NUM]
  FROM [dbo].[TB_LOGIN]
 WHERE [CHARACTER_NAME]=@CHARACTER_NAME
   AND [APPLY]=1

' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_GAMEOUT_COMPLETE]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'

/**********************************************************************
 *<
	FILE: GP_GAMEOUT_COMPLETE.SQL

	DESCRIPTION:

	CREATED BY:

	HISTORY:

 *>	Copyright (c) 2009, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_GAMEOUT_COMPLETE]
	(@LOGIN_IDX [int])					--고유번호 - 로그 테이블

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

UPDATE [dbo].[TB_LOGIN] 
   SET [CHARACTER_NAME]=NULL		--캐릭터이름.
 WHERE [IDX]=@LOGIN_IDX

' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_COMEIN_GAME]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'

/**********************************************************************
 *<
	FILE: GP_COMEIN_GAME.SQL

	DESCRIPTION: 멤버 업데이트

	CREATED BY: 곽철중

	HISTORY: Created	01/23/07	SQLServer2000
			 Modified	02/26/07	SQLServer2005
			 Modified	02/26/07	RENAME GP_MEMBER_UPDATE TO GP_COMEIN_GAME

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_COMEIN_GAME]
	(@LOGIN_IDX 		[int]					--고유번호 - 로그 테이블
	,@SERVER_NUM		[int]					--서버번호
	,@CHANNEL_NUM		[int]					--채널번호
	,@LAST_CHANNEL		[int]					--이전채널
	,@CHARACTER_IDX		[int]					--고유번호 - 캐릭터 테이블
	,@INSTANT_DUNGEON	[tinyint]				--인던여부
	,@IPV4				[int]OUTPUT	            --IPv4
	,@PORT				[smallint]OUTPUT	    --Port
	,@RETVALUE			[int]OUTPUT)			--반환값

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

SELECT @IPV4=[IPV4]
      ,@PORT=[PORT]
  FROM [dbo].[TB_CHANNEL]
 WHERE [SERVER_NUM]=@SERVER_NUM
   AND [CHANNEL_NUM]=@CHANNEL_NUM
   AND [STATUS] <> 0

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	BEGIN
		SET @RETVALUE = 1 --미등록 서버검색.
	END
ELSE
	BEGIN
		UPDATE [dbo].[TB_LOGIN] 
		   SET [LAST_DATE]=GETDATE()
              ,[SERVER_NUM]=@SERVER_NUM				--서버번호.
		 	  ,[CHANNEL_NUM]=@CHANNEL_NUM			--채널번호.
			  ,[LAST_CHANNEL]=@LAST_CHANNEL			--이전채널.
		 	  ,[CHARACTER_IDX]=@CHARACTER_IDX		--캐릭터번호.
			  ,[INSTANT_DUNGEON]=@INSTANT_DUNGEON	--0사용안함/1사용중
			  ,[APPLY]=0							--0대기중/1사용중.
		 WHERE [IDX]=@LOGIN_IDX

		IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
			BEGIN
				SET @RETVALUE = 2 --알수없는 오류.
			END
		ELSE
			BEGIN
				SET @RETVALUE = 0 --업데이트 성공.
			END
	END
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_CHANNEL_CHECK]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'




/**********************************************************************
 *<
	FILE: GP_CHANNEL_CHECK.SQL

	DESCRIPTION: 게임서버등록(채널등록)

	CREATED BY: 곽철중

	HISTORY: 01/31/07 Created

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_CHANNEL_CHECK]
	(@SERVER_NUM	[int]					--서버번호
	,@SERVER_NAME	[varchar](50)OUTPUT		--서버이름
	,@SERVER_DESC	[varchar](200)OUTPUT	--서버설명
	,@CHANNEL_NUM	[int]OUTPUT				--채널번호
	,@INETNUM	 	[varchar](20)			--채널IP주소(IPv4)
	,@IPV4          [int]					--채널IP주소(IPv4)
	,@PORT          [smallint]              --PORT
	,@RETVALUE		[int]OUTPUT)			--반환값

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

SELECT @SERVER_NAME=[NAME]
	  ,@SERVER_DESC=[DESCRIPTION]
  FROM [dbo].[TB_SERVER]
 WHERE [IDX]=@SERVER_NUM

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	GOTO ERROR1

IF @CHANNEL_NUM <> 0
	BEGIN
		IF EXISTS (SELECT *
				     FROM [dbo].[TB_CHANNEL]
					WHERE [SERVER_NUM]=@SERVER_NUM
					  AND [CHANNEL_NUM]=@CHANNEL_NUM)
			GOTO ERROR2
	END
ELSE
	BEGIN
		SELECT TOP 1 @CHANNEL_NUM=[CHANNEL_NUM]
		  FROM [dbo].[TB_MATRIX] M
		 WHERE [SERVER_NUM]=@SERVER_NUM
		   AND NOT EXISTS (SELECT [CHANNEL_NUM]
							 FROM [dbo].[TB_CHANNEL] S
							WHERE (M.SERVER_NUM=S.SERVER_NUM)
							  AND (M.CHANNEL_NUM=S.CHANNEL_NUM))
		 ORDER BY [CHANNEL_NUM] ASC

		IF @CHANNEL_NUM = 0
			GOTO ERROR3
	END

INSERT INTO [dbo].[TB_CHANNEL]
	([SERVER_NUM]
	,[CHANNEL_NUM]
	,[INETNUM]
	,[IPV4]
	,[PORT])
VALUES
	(@SERVER_NUM
	,@CHANNEL_NUM
	,@INETNUM
	,@IPV4
	,@PORT)

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	GOTO ERROR4

--등록성공.
SET @RETVALUE = 0
RETURN

ERROR1: --등록실패 - 등록안된 서버번호 사용.
	SET @RETVALUE = 1
	RETURN

ERROR2: --등록실패 - 이미 사용중 채널번호.
	SET @RETVALUE = 2
	RETURN

ERROR3: --등록실패 - TB_MATRIX 테이블 오류.
	SET @RETVALUE = 3
	RETURN

ERROR4: --등록실패 - 알수없는 오류.
	SET @RETVALUE = 4
	RETURN

' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_MATRIX_CREATE]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'

/**********************************************************************
 *<
	FILE: GP_MATRIX_CREATE.SQL

	DESCRIPTION: 매트릭스 테이블 생성

	CREATED BY: 곽철중

	HISTORY: Created	02/08/07	SQLServer2000
			 Modified	02/26/07	SQLServer2005

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_MATRIX_CREATE]
	(@MAX_SERVER	[int]			--최대 서버번호
	,@MAX_CHANNEL	[int]			--최대 채널번호
	,@RETVALUE		[int]OUTPUT)	--반환값

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

DECLARE @ERRORCODE	[int]
DECLARE @ROWCOUNT	[int]

DECLARE @SERVER		[int]
DECLARE @CHANNEL	[int]

SET @SERVER  = 1
SET @CHANNEL = 1

--TRUNCATE TABLE [dbo].[TB_MATRIX]

WHILE (@SERVER <= @MAX_SERVER)
	BEGIN
		WHILE (@CHANNEL <= @MAX_CHANNEL)
			BEGIN
				IF NOT EXISTS (SELECT * FROM [dbo].[TB_MATRIX] WHERE [SERVER_NUM]=@SERVER AND [CHANNEL_NUM]=@CHANNEL)
					BEGIN
						INSERT [dbo].[TB_MATRIX]
							  ([SERVER_NUM]
							  ,[CHANNEL_NUM])
						VALUES(@SERVER
							  ,@CHANNEL)

						SELECT @ERRORCODE = @@ERROR, @ROWCOUNT = @@ROWCOUNT

						IF @ERRORCODE <> 0 OR @ROWCOUNT <> 1
							BEGIN
								SET @RETVALUE = -1	--Unknown Error
								RETURN @ERRORCODE
							END
					END
 
				SET @CHANNEL = @CHANNEL + 1
			END
		SET @CHANNEL = 1
		SET @SERVER  = @SERVER + 1
	END

SET @RETVALUE = 0	-- 생성성공.
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_MATRIX_SELECT]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'


/**********************************************************************
 *<
	FILE: GP_MATRIX_SELECT.SQL

	DESCRIPTION:

	CREATED BY: 곽철중

	HISTORY:

 *>	Copyright (c) 2008, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_MATRIX_SELECT]
	(@MAX_SERVER	[int]OUTPUT,	--최대 서버번호
	 @MAX_CHANNEL	[int]OUTPUT)	--최대 채널번호

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

SELECT @MAX_SERVER=MAX([SERVER_NUM])
      ,@MAX_CHANNEL=MAX([CHANNEL_NUM])
  FROM [dbo].[TB_MATRIX]
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_CHANNEL_UPDATE]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'



/**********************************************************************
 *<
	FILE: GP_CHANNEL_UPDATE.SQL

	DESCRIPTION: 게임서버(채널) 업데이트

	CREATED BY: 곽철중

	HISTORY: Created	01/31/07	SQLServer2000
			 Modified	02/26/07	SQLServer2005

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_CHANNEL_UPDATE]
	(@SERVER_NUM 	[int],		--서버번호
	 @CHANNEL_NUM	[int],		--채널번호
	 @STATUS 		[tinyint],		--상태(0원활/1보통/2혼잡)
	 @RETVALUE		[int]OUTPUT)	--반환값

AS

UPDATE [dbo].[TB_CHANNEL]
   SET [STATUS]=@STATUS
 WHERE [SERVER_NUM]=@SERVER_NUM
   AND [CHANNEL_NUM]=@CHANNEL_NUM

IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
	BEGIN
		SET @RETVALUE = 1 --알수없는 오류.
	END
ELSE
	BEGIN
		SET @RETVALUE = 0 --업데이트 성공.
	END

' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GP_SERVER_LIST]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'



/**********************************************************************
 *<
	FILE: GP_SERVER_LIST.SQL

	DESCRIPTION: 로그인

	CREATED BY: 곽철중

	HISTORY: Created	03/29/07

 *>	Copyright (c) 2007, All Rights Reserved.
 **********************************************************************/

CREATE PROCEDURE [dbo].[GP_SERVER_LIST]

AS

SET NOCOUNT ON -- 영향받은 행의 갯수를 반환하지 않는다.

SELECT [IDX]
	  ,[NAME]
	  ,[DESCRIPTION]
	  ,[STATUS]
  FROM [dbo].[TB_SERVER]
 WHERE [APPLY] = 0
 ORDER BY [IDX] ASC
' 
END
