Как насчет следующих SQL ...
SQL
-- DDL and sample data population, start
DECLARE @tbl TABLE (effworkruleid int, zonename VARCHAR(30));
INSERT INTO @tbl (effworkruleid, zonename)
VALUES (333, 'g')
,(333 , 'f')
,(333 , 'y')
,(222 , 'x')
,(222 , 'y')
,(222 , 'z')
,(111 , 'E')
,(111 , 'F')
,(444 , 'L');
-- DDL and sample data population, end
DECLARE @separator CHAR(1) = ','
, @Lf CHAR(1) = CHAR(10);
SELECT DISTINCT c.effworkruleid
, REPLACE(
STUFF((SELECT CONCAT(@separator, CAST(zonename AS VARCHAR(30))) AS [text()]
FROM @tbl AS O
WHERE O.effworkruleid = C.effworkruleid
ORDER BY effworkruleid, zonename ASC
FOR XML PATH('')), 1, 1, NULL), @separator, @Lf)
AS zonename_List
FROM @tbl AS C;