IT/DB

[MSSQL] 변수 LIKE절 활용 프로시져

Dev. Sean 2022. 3. 22. 09:10
반응형
SELECT A.CHECKID, A.HOSTID, A.DUTYUSER, B.SYSTEMNAME, B.HOST
FROM OPRHOSTCHECKDETAIL AS A WITH(NOLOCK)
LEFT OUTER JOIN OPRHOSTIPCODE AS B WITH(NOLOCK) ON A.HOSTID = B.HOSTID
LEFT OUTER JOIN OPRHOSTCHECKMASTER AS C WITH(NOLOCK) ON A.CHECKID = C.CHECKID
WHERE A.CHECKID = @I_CHECKID
AND OPRTEAM LIKE @I_OPRTEAM
AND A.DUTYUSER LIKE '%' + @I_DUTYUSER + '%'
AND B.SYSTEMNAME LIKE '%' + @I_SYSTEMNAME + '%'

% + 변수명 +% 

 

이렇게 하면된다

반응형