MS-SQL Stored Procedure 샘플
USE [{{DB_NAME}}]
GO
/****** Object: StoredProcedure [dbo].[{{SP_NAME}}] Script Date: 2019-04-18 오후 2:59:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[{{SP_NAME}}]
@PLAN_YYYY CHAR(4), -- 계획년도
@REGION CHAR(1), -- 지역구분
@DEPT_CODE CHAR(5), -- 부서코드
@POSITION_CODE VARCHAR(3), -- 직급
@PLAN_YYYYMM SMALLDATETIME, -- 계획년월
@INPUT_PLAN SMALLINT, -- 투입계획
@INPUT_REASON NVARCHAR(100) = NULL, -- 투입사유
@OUT_PLAN SMALLINT, -- 유출계획
@OUT_REASON NVARCHAR(100) = NULL, -- 유출사유
@EMP_NUM CHAR(6) -- 입력자
AS
SET NOCOUNT ON
/*===================================================================
모듈명 또는 시스템명 :
프로시저명 :
기능설명 :
비고/특이사항 :
실행 :
===================================================================
변경이력
-------------------------------------------------------------------
일자 작성자 CSR No. 변경내역
----------- -------- -------- ----------------------------------
===================================================================*/
IF @INPUT_REASON = '' OR @INPUT_PLAN = 0 SELECT @INPUT_REASON = NULL
IF @OUT_REASON = '' OR @OUT_PLAN = 0 SELECT @OUT_REASON = NULL
IF NOT EXISTS (
SELECT *
FROM {{TABLE_NAME}} A WITH(NOLOCK, INDEX = 1)
WHERE A.PLAN_YYYY = @PLAN_YYYY
AND A.REGION = @REGION
AND A.DEPT_CODE = @DEPT_CODE
AND A.POSITION_CODE = @POSITION_CODE
)
BEGIN
INSERT {{TABLE_NAME}}
VALUES (@PLAN_YYYY, @REGION, @DEPT_CODE, @POSITION_CODE, 0)
IF @@ERROR <> 0 RETURN
END
-- 주석 테스트 이것까지
/***
/*
-- 주석 테스트 이것까지
*/
****/
INSERT {{TABLE_NAME}}
VALUES (@PLAN_YYYY, @REGION, @DEPT_CODE, @POSITION_CODE, @PLAN_YYYYMM, @INPUT_PLAN, @INPUT_REASON, @OUT_PLAN, @OUT_REASON, @INPUT_PLAN, @OUT_PLAN, @EMP_NUM)
IF @@ERROR <> 0 RETURN
/*
IF EXISTS (SELECT * FROM {{TABLE_NAME}} (NOLOCK INDEX = 1) WHERE PN_YY = @PN_YY AND X_DTY = @X_DTY AND C_DPT = @C_DPT AND C_POS = @C_POS AND PN_YM = @PN_YM)
BEGIN
IF @Q_EUP = 0 AND @Q_EDN = 0 AND @X_EUP IS NULL AND @X_EDN IS NULL
DELETE FROM {{TABLE_NAME}} WHERE PN_YY = @PN_YY AND X_DTY = @X_DTY AND C_DPT = @C_DPT AND C_POS = @C_POS AND PN_YM = @PN_YM
ELSE
UPDATE {{TABLE_NAME}}
SET Q_EUP = @Q_EUP, X_EUP = @X_EUP, Q_EDN = @Q_EDN, X_EDN = @X_EDN, Q_EUPC = @Q_EUP, Q_EDNC = @Q_EDN, N_EMP_IG = @N_EMP
WHERE PN_YY = @PN_YY AND X_DTY = @X_DTY AND C_DPT = @C_DPT AND C_POS = @C_POS AND PN_YM = @PN_YM
IF @@ERROR <> 0 RETURN
END
ELSE
BEGIN
IF NOT (@Q_EUP = 0 AND @Q_EDN = 0 AND @X_EUP IS NULL AND @X_EDN IS NULL )
BEGIN
IF NOT EXISTS (SELECT * FROM {{TABLE_NAME}} (NOLOCK INDEX = 1) WHERE PN_YY = @PN_YY AND X_DTY = @X_DTY AND C_DPT = @C_DPT AND C_POS = @C_POS)
BEGIN
INSERT {{TABLE_NAME}} VALUES (@PN_YY, @X_DTY, @C_DPT, @C_POS, 0)
IF @@ERROR <> 0 RETURN
END
INSERT {{TABLE_NAME}} VALUES (@PN_YY, @X_DTY, @C_DPT, @C_POS, @PN_YM, @Q_EUP, @X_EUP, @Q_EDN, @X_EDN, @Q_EUP, @Q_EDN, @N_EMP)
IF @@ERROR <> 0 RETURN
END
END
*/
SELECT -1
regex : (\/\*([^*]|[\r\n]|(\*+([^\*\/]|[\r\n])))*\*+\/)|(\/\/.*)|(\-\-(.*)[\r\n])|((.*)\*\/)
demo link : https://regexr.com/4cgnu
'Tip' 카테고리의 다른 글
쿠팡 파트너스 (0) | 2019.08.05 |
---|---|
regex - 힌트를 사용하지만 WITH가 없는 쿼리 문자열 찾기 (0) | 2019.06.26 |
[IDE][Visual Studio 2017 Community] 파일이나 어셈블리 'SqlPackageBase, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' 또는 여기에 종속되어 있는 파일이나 어셈블리 중 하나를 로드할 수 없습니다. .. (0) | 2017.11.17 |
[IDE][Visual Studio2017 Community] v15.2 Syntax HighLight issue (0) | 2017.11.17 |
아파트 평면도 제공하는 곳 (0) | 2017.07.12 |