[ms-sql] where절에 like 조건으로 계좌번호 찾기
where절에 like 조건으로 계좌번호 찾는 방법
WHERE Contents LIKE ‘%[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]%’ –농협계좌번호
계좌번호 마스킹 처리
SELECT
LEFT(LTRIM(RTRIM(Contents)), PATINDEX(‘%[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]%’,LTRIM(RTRIM(Contents)))+6 ) +’******’
+ RIGHT(LTRIM(RTRIM(Contents)), len(LTRIM(RTRIM(Contents))) – patindex(‘%[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]%’,LTRIM(RTRIM(Contents)))-12) AS Change_Contents
,PATINDEX(‘%[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]%’,LTRIM(RTRIM(Contents))) AS POSITION
FROM TB_TEST
WHERE Contents LIKE ‘%[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]%’ –농협계좌번호