DB 데이타 일관 처리 프로세서
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Create PROCEDURE Pro_GetMutilCode @cityCode VARCHAR(3) AS BEGIN DECLARE @muticodeArr varchar(100),@apCode varchar(3) SET @muticodeArr=@cityCode; Declare con_cursor cursor for SELECT AP_CODE FROM AIRPORTCODE WHERE AP_CITY_CODE=@cityCode open con_cursor --커스를 연다. fetch next from con_cursor into @apCode while (@@fetch_status <>-1) begin if (@@fetch_status = -2) continue begin -- 처리 set @muticodeArr += '-' + @apCode end fetch next from con_cursor into @apCode end close con_cursor Deallocate con_cursor SELECT @muticodeArr as MC_GROUP_CITY, @cityCode as MC_CITY END |
STRING_SPLIT
문장을 구분으로 잘라 List 로 보여주기.
(2016 버전 부터 적용가능)
1 2 3 4 5 6 7 |
SELECT RULE_NO , RULE_NAME , RULE_CONTENTS FROM RULE CROSS APPLY STRING_SPLIT(RULE_CONTENTS, ' ') |