This is the stored procedure:
CREATE PROCEDURE [dbo].[StoredProcedure]
@FILTERNAME varchar(100) = ''
AS
IF @FILTERNAME <> ''
BEGIN
SELECT
CODE, NAMEen, NAMEkr
FROM
(SELECT
OT.CODE, OT.NAMEen, OT.NAMEkr, OT.Sortkey
FROM
OptionTable OT
INNER JOIN
ConditionTable CT ON OT.CODE = CT.CODE
INNER JOIN
MasterTable MT ON CT.DevCode = MT.DevCode
AND CT.PlanCode = MT.PlanCode
WHERE
MT.ProductName LIKE '%' + @FILTERNAME + '%'
GROUP BY
OT.CODE, OT.NAMEen, OT.NAMEkr, OT.Sortkey) TBL
ORDER BY
Sortkey
END
This stored procedure is called from vb6. I cant touch the vb6's code so I need to fix this.
Until now, the parameter was like 'XXX', but it's going to be like 'A,BB,CCC,ZZZZ'.
I need to split the parameter's string by ,
and change the condition like this: when the parameter is something like this 'A,BB,CCC,ZZZZ'
, then use this WHERE
condition:
WHERE MT.ProductName LIKE '%' + A + '%'
or MT.ProductName LIKE '%' + BB + '%'
or MT.ProductName LIKE '%' + CCC + '%'
or MT.ProductName LIKE '%' + ZZZZ + '%'
Can someone help me? Thanks.