0

I have a stored procedure like this:

ALTER PROC FindPolicyByService
    @codes varchar(200)
AS 
BEGIN
    SELECT dbo.DXBusinessPolicy_Policy.Code AS PolicyCode,
           dbo.DXBusinessPolicy_Policy.Name AS PolicyName,
           dbo.DXBusinessPolicy_Service.Name AS ServiceName
        FROM dbo.DXBusinessPolicy_Policy 
            join dbo.DXBusinessPolicy_PolicyService ON dbo.DXBusinessPolicy_Policy.ID = dbo.DXBusinessPolicy_PolicyService.PolicyID
            join dbo.DXBusinessPolicy_Service ON dbo.DXBusinessPolicy_PolicyService.ServiceID = dbo.DXBusinessPolicy_Service.ID
        WHERE dbo.DXBusinessPolicy_Service.Code IN (select value from string_split(@codes,','))
END

exec FindPolicyByService "ott,cmr"

this is the result when I execute it

PolicyCode PolicyName ServiceName
1 COMBO.2103002 Giá nền combo T04.2021 Camera
2 COMBO.2103002 Giá nền combo T04.2021 OTT
3 COMBO.2103003 Combo T5.2021 Camera
4 COMBO.2103003 Combo T5.2021 OTT

but this is my expectation

PolicyCode PolicyName ServiceName
1 COMBO.2103002 Giá nền combo T04.2021 Camera, OTT
2 COMBO.2103003 Combo T5.2021 Camera, OTT

I don't know if there is a way to do that, thanks for everyone's help

Dale K
  • 21,987
  • 13
  • 41
  • 69
nsnd64
  • 59
  • 8

0 Answers0