USE [master]
GO
/****** Object:  Database [OperatorTool]    Script Date: 12/20/2015 6:09:40 PM ******/
CREATE DATABASE [OperatorTool]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'OperatorTool', FILENAME = N'D:\SQL SERVER DATA\SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\OperatorTool.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'OperatorTool_log', FILENAME = N'D:\SQL SERVER DATA\SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\OperatorTool_1.ldf' , SIZE = 6272KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [OperatorTool] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [OperatorTool].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [OperatorTool] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [OperatorTool] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [OperatorTool] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [OperatorTool] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [OperatorTool] SET ARITHABORT OFF 
GO
ALTER DATABASE [OperatorTool] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [OperatorTool] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [OperatorTool] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [OperatorTool] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [OperatorTool] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [OperatorTool] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [OperatorTool] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [OperatorTool] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [OperatorTool] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [OperatorTool] SET  DISABLE_BROKER 
GO
ALTER DATABASE [OperatorTool] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [OperatorTool] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [OperatorTool] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [OperatorTool] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [OperatorTool] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [OperatorTool] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [OperatorTool] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [OperatorTool] SET RECOVERY FULL 
GO
ALTER DATABASE [OperatorTool] SET  MULTI_USER 
GO
ALTER DATABASE [OperatorTool] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [OperatorTool] SET DB_CHAINING OFF 
GO
ALTER DATABASE [OperatorTool] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [OperatorTool] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
ALTER DATABASE [OperatorTool] SET DELAYED_DURABILITY = DISABLED 
GO
USE [OperatorTool]
GO
/****** Object:  User [Stormy-PC\Administrator]    Script Date: 12/20/2015 6:09:41 PM ******/
CREATE USER [Stormy-PC\Administrator] FOR LOGIN [Stormy-PC\Administrator] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object:  User [NT AUTHORITY\SYSTEM]    Script Date: 12/20/2015 6:09:41 PM ******/
CREATE USER [NT AUTHORITY\SYSTEM] FOR LOGIN [NT AUTHORITY\SYSTEM] WITH DEFAULT_SCHEMA=[dbo]
GO
ALTER ROLE [db_owner] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_accessadmin] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_securityadmin] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_ddladmin] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_backupoperator] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_datareader] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_denydatareader] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_denydatawriter] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_owner] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_accessadmin] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_securityadmin] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_ddladmin] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_backupoperator] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_datareader] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_denydatareader] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_denydatawriter] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
/****** Object:  Table [dbo].[tMenuAuth]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tMenuAuth](
	[no] [tinyint] NOT NULL,
	[menu] [char](20) NOT NULL,
	[auth] [tinyint] NOT NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[tOperator]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tOperator](
	[nOperNo] [int] IDENTITY(1,1) NOT NULL,
	[sOperID] [nvarchar](20) NOT NULL,
	[sOperPW] [nvarchar](20) NOT NULL,
	[nOperLevel] [tinyint] NOT NULL DEFAULT ((0)),
	[dRegDate] [datetime] NOT NULL DEFAULT (getdate()),
PRIMARY KEY CLUSTERED 
(
	[nOperNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
	[sOperID] 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].[tOpLog]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tOpLog](
	[nNo] [int] IDENTITY(1,1) NOT NULL,
	[dDate] [datetime] NOT NULL DEFAULT (getdate()),
	[nOperNo] [smallint] NOT NULL,
	[sIP] [nvarchar](20) NOT NULL,
	[nType] [smallint] NOT NULL,
	[nUserNo] [int] NULL DEFAULT ((0)),
	[sServer] [nvarchar](50) NULL,
	[nCharNo] [int] NULL DEFAULT ((0)),
	[sDesc] [nvarchar](256) NULL,
PRIMARY KEY CLUSTERED 
(
	[nNo] 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:  StoredProcedure [dbo].[p_Operator_Add]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_Operator_Add]
/*
Operator add
input:
  See SQL
output: 
  nOperNo = 추가된 Operator의 번호(에러시 = 0 )
*/
@nOperNo	int OUTPUT,
@sOperID	nvarchar(20),
@sOperPW	nvarchar(20),
@nOperLevel	tinyint
AS
SET NOCOUNT ON
SET @nOperNo = 0
INSERT tOperator (  sOperID,  sOperPW,  nOperLevel )
VALUES           ( @sOperID, @sOperPW, @nOperLevel )
IF @@ERROR = 0
	SET @nOperNo = @@IDENTITY
	
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_Operator_Del]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_Operator_Del]
/*
Operator delete
input:
  See SQL
output: 
  @nOperLevel = 0, Delete failed
                1, Delete successed
*/
@nOperNo	int,
@nOperLevel tinyint OUTPUT
AS
SET NOCOUNT ON
SET @nOperLevel = 0
DELETE FROM tOperator WHERE nOperNo = @nOperNo
IF @@ROWCOUNT > 0
	SET @nOperLevel = 1
	
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_Operator_GetAll]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_Operator_GetAll]
/*
  Operator Get All
  output:
   - Select된 데이타
*/
AS
SET NOCOUNT ON
SELECT nOperNo, sOperID, nOperLevel, dRegDate FROM tOperator
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_Operator_Logon]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_Operator_Logon]
/*
Operator logon
2004.12 By CJC
- Check ID.Password
Output:
	@nOperNo = 0 Failed logon (ID,Password missmatch) 
			 = ? Successed logon ( @nOperLevel = Operator level )
*/
@sOperID	nvarchar(20),
@sOperPW	nvarchar(20),
@nOperNo	int OUTPUT,
@nOperLevel	int OUTPUT
AS
SET NOCOUNT ON
SET @nOperNo = 0
IF EXISTS(SELECT * FROM tOperator WHERE (sOperID = @sOperID) AND (sOperPW = @sOperPW) )
BEGIN
	SELECT @nOperNo = nOperNo, @nOperLevel = nOperLevel 
	FROM tOperator WHERE (sOperID = @sOperID) AND (sOperPW = @sOperPW)
END
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_Operator_SetLevel]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_Operator_SetLevel]
/*
Operator set level
input:
  See SQL
output: 
  nRet = 1 TRUE
	   = 0 FALSE
*/
@nOperNo	int,
@nOperLevel	tinyint,
@nRet		int OUTPUT
AS
SET NOCOUNT ON
UPDATE tOperator SET nOperLevel = @nOperLevel WHERE nOperNo = @nOperNo
IF (@@ERROR = 0) AND (@@ROWCOUNT = 1)
	SET @nRet = 1
ELSE
	SET @nRet = 0
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_Operator_SetPW]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_Operator_SetPW]
/*
Operator set password
input:
  See SQL
output: 
  nRet = 1 TRUE
	   = 0 FALSE
*/
@nOperNo	int,
@sOperPW	nvarchar(20),
@nRet		int OUTPUT
AS
SET NOCOUNT ON
UPDATE tOperator SET sOperPW = @sOperPW WHERE nOperNo = @nOperNo
IF (@@ERROR = 0) AND (@@ROWCOUNT = 1)
	SET @nRet = 1
ELSE
	SET @nRet = 0
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_OPLog_Add]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_OPLog_Add]
/*
 Operator log add
 input:
  All Args = 로그에 기록될 정보
 output: 
  nLogNo = 추가된 로그의 번호(에러시 LogNo = 0 )
*/
@nLogType	tinyint,
@nOperNo	smallint,
@sIP		nvarchar(20),
@nType		smallint,
@nUserNo	int,
@sServer	nvarchar(50),
@nCharNo	int,
@sDesc		nvarchar(200),
@nLogNo		int OUTPUT
AS
BEGIN
SET NOCOUNT ON
SET @nLogNo = 0
DECLARE @STMT	AS NVARCHAR(200)
SET @STMT = 'INSERT tOpLog ' + 
	CASE @nLogType
		WHEN 0 THEN		'( nOperNo,		sIP,	nType,	nUserNo,	sServer,	nCharNo,	sDesc )
				VALUES	 ( @nOperNo,	@sIP,	@nType, @nUserNo,	@sServer,	@nCharNo,	@sDesc )'
		WHEN 1 THEN		'( nOperNo,		sIP,	nType,	sDesc )
				VALUES	 ( @nOperNo,	@sIP,	@nType, @sDesc )'
		WHEN 2 THEN		'( nOperNo,		sIP,	nType,	nUserNo,	sServer,	sDesc )
				VALUES	 ( @nOperNo,	@sIP,	@nType, @nUserNo,	@sServer,	@sDesc )'
		WHEN 3 THEN		'( nOperNo,		sIP,	nType,	sServer,	sDesc )
				VALUES	 ( @nOperNo,	@sIP,	@nType, @sServer,	@sDesc )'
	END
PRINT @STMT
EXEC sp_executesql @STMT
SET @nLogNo = @@IDENTITY
END
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_OPLog_Add_All]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_OPLog_Add_All]
/*
 Operator log add
 input:
  All Args = 로그에 기록될 정보
 output: 
  nLogNo = 추가된 로그의 번호(에러시 LogNo = 0 )
*/
@nOperNo	smallint,
@sIP		nvarchar(20),
@nType		smallint,
@nUserNo	int,
@sServer	nvarchar(50),
@nCharNo	int,
@sDesc		nvarchar(200),
@nLogNo		int OUTPUT
AS
SET NOCOUNT ON
SET @nLogNo = 0
INSERT tOpLog ( nOperNo,	sIP,	nType,	nUserNo,	sServer,	nCharNo,	sDesc )
VALUES        ( @nOperNo,	@sIP,	@nType, @nUserNo,	@sServer,	@nCharNo,	@sDesc )
SET @nLogNo = @@IDENTITY
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_OPLog_Add_ToIP]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_OPLog_Add_ToIP]
/*
 Operator log add
 input:
  All Args = 로그에 기록될 정보
 output: 
  nLogNo = 추가된 로그의 번호(에러시 LogNo = 0 )
*/
@nOperNo	smallint,
@sIP		nvarchar(20),
@nType		smallint,
@sServer	nvarchar(50),
@sDesc		nvarchar(200),
@nLogNo		int OUTPUT
AS
SET NOCOUNT ON
SET @nLogNo = 0
INSERT tOpLog ( nOperNo,	sIP,	nType,	sServer,	sDesc )
VALUES        ( @nOperNo,	@sIP,	@nType, @sServer,	@sDesc )
SET @nLogNo = @@IDENTITY
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_OPLog_Add_ToUserNo]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_OPLog_Add_ToUserNo]
/*
 Operator log add
 input:
  All Args = 로그에 기록될 정보
 output: 
  nLogNo = 추가된 로그의 번호(에러시 LogNo = 0 )
*/
@nOperNo	smallint,
@sIP		nvarchar(20),
@nType		smallint,
@nUserNo	int,
@sServer	nvarchar(50),
@sDesc		nvarchar(200),
@nLogNo		int OUTPUT
AS
SET NOCOUNT ON
SET @nLogNo = 0
INSERT tOpLog ( nOperNo,	sIP,	nType,	nUserNo,	sServer,	sDesc )
VALUES        ( @nOperNo,	@sIP,	@nType, @nUserNo,	@sServer,	@sDesc )
SET @nLogNo = @@IDENTITY
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_OPLog_Add_ToWorldNo]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_OPLog_Add_ToWorldNo]
/*
 Operator log add
 input:
  All Args = 로그에 기록될 정보
 output: 
  nLogNo = 추가된 로그의 번호(에러시 LogNo = 0 )
*/
@nOperNo	smallint,
@sIP		nvarchar(20),
@nType		smallint,
@sServer	nvarchar(50),
@sDesc		nvarchar(200),
@nLogNo		int OUTPUT
AS
SET NOCOUNT ON
SET @nLogNo = 0
INSERT tOpLog ( nOperNo,	sIP,	nType,	sServer,	sDesc )
VALUES        ( @nOperNo,	@sIP,	@nType, @sServer,	@sDesc )
SET @nLogNo = @@IDENTITY
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_OPLog_Get]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_OPLog_Get]
/*
  OPLog Get - 주어진 조건에 맞는 로그를 모두검색해서 얻는다.
  input:
   - 주어진 조건절
  output:
   - Select된 데이타
*/
@WhereExpr nvarchar(256)
AS
SET NOCOUNT ON
DECLARE @SQLCMD nvarchar(512)
SET @SQLCMD = N'SELECT nNo, dDate, nOperNo, sIP, nType, nUserNo, sServer, nCharNo, sDesc FROM tOpLog ' + @WhereExpr
EXEC sp_executesql @SQLCMD
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_OPLog_GetCount]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[p_OPLog_GetCount]
/*
  OPLog Get Count - 주어진 조건에 맞는 로그를 모두검색해서 얻는다.
  input:
   - 주어진 조건절
  output:
   - @Count = 해당 조건에 만족하는 레코드수
*/
@WhereExpr nvarchar(256),
@Count int OUTPUT
AS
SET NOCOUNT ON
DECLARE @SQLCMD nvarchar(512)
SET @SQLCMD = N'SELECT @RowCount = COUNT(*) FROM tOpLog ' + @WhereExpr
EXEC sp_executesql @SQLCMD, N'@RowCount AS int OUTPUT', @RowCount = @Count OUTPUT
-- end

GO
/****** Object:  StoredProcedure [dbo].[p_OPTMenu_GetAuth]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
'--------------------------------------------------------------------------------------
' 함수명 : p_OPTMenu_GetAuth
' 내  용 : OP Tool Menu 에 대한 접근 권한을 얻어옴
' 작성자 : 이병기
' 작성일 : 2005년 12월 20일
' 버  젼 : 1.0
' 인  자 :
'			input Parameter
'				@sMenuName	: 메뉴이름
'			RETURN_VALUE
'--------------------------------------------------------------------------------------
*/
CREATE PROCEDURE [dbo].[p_OPTMenu_GetAuth]
@sMenuName	NVARCHAR(20)
AS
SET NOCOUNT ON
SELECT auth FROM tMenuAuth WHERE menu = @sMenuName

GO
/****** Object:  StoredProcedure [dbo].[p_OPTMenu_GetAuthAll]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
'--------------------------------------------------------------------------------------
' 함수명 : p_OPTMenu_GetAuthAll
' 내  용 : OP Tool Menu 에 대한 접근 권한을 얻어옴
' 작성자 : 이병기
' 작성일 : 2005년 12월 20일
' 버  젼 : 1.0
' 인  자 :
'			input Parameter
'				
'			RETURN_VALUE
'
'--------------------------------------------------------------------------------------
*/
CREATE PROCEDURE [dbo].[p_OPTMenu_GetAuthAll]
AS
SET NOCOUNT ON
SELECT no, menu, auth FROM tMenuAuth

GO
/****** Object:  StoredProcedure [dbo].[p_OPTMenu_GetCount]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
'--------------------------------------------------------------------------------------
' 함수명 : p_OPTMenu_GetCount
' 내  용 : 접근 권한을 정해 놓기 위해 디비에 등록한 메뉴의 갯수를 얻어옴
' 작성자 : 이병기
' 작성일 : 2005년 12월 20일
' 버  젼 : 1.0
' 인  자 :
'			input Parameter
'			
'			output Parameter
'				@nCount int OUTPUT
'			RETURN_VALUE
'
'--------------------------------------------------------------------------------------
*/
CREATE PROCEDURE [dbo].[p_OPTMenu_GetCount]
@nCount tinyint OUTPUT
AS
SET NOCOUNT ON
SELECT @nCount = COUNT(*) FROM tMenuAuth

GO
/****** Object:  StoredProcedure [dbo].[p_OPTMenu_SetAuth]    Script Date: 12/20/2015 6:09:41 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
'--------------------------------------------------------------------------------------
' 함수명 : p_OPTMenu_SetAuth
' 내  용 : OP Tool Menu 에 대한 접근 권한을 세팅
' 작성자 : 이병기
' 작성일 : 2005년 12월 20일
' 버  젼 : 1.0
' 인  자 :
'			input Parameter
'				@sMenuName	: 메뉴이름
'				@nAuth		: 접근 권한 하위 한계
'			RETURN_VALUE
'				 1 : 등록
'				 0 : DB ERROR (INSERT)
'--------------------------------------------------------------------------------------
*/
CREATE PROCEDURE [dbo].[p_OPTMenu_SetAuth]
@sMenuName	NVARCHAR(20),
@nAuth		tinyint,
@nRet		int OUTPUT
AS
SET NOCOUNT ON
UPDATE tMenuAuth SET auth = @nAuth WHERE menu = @sMenuName
IF (@@ERROR = 0) AND (@@ROWCOUNT = 1)
	SET @nRet = 1
ELSE
	SET @nRet = 0

GO
USE [master]
GO
ALTER DATABASE [OperatorTool] SET  READ_WRITE 
GO
