You can try this
DECLARE @txnid int
DECLARE @table table (Txnid INT,Items VARCHAR(15))
DECLARE cur CURSOR FOR
SELECT DISTINCT trans.Txnid FROM trans
OPEN cur
FETCH NEXT FROM cur INTO @txnid
WHILE @@FETCH_STATUS =0
BEGIN
INSERT INTO @table
SELECT @txnid Txnid,STUFF((SELECT ','+items FROM Items WHERE itemid in(SELECT itemid FROM trans WHERE txnid=@txnid) FOR XML PATH('')),1,1,'')Items
FETCH NEXT FROM cur INTO @txnid
END
SELECT * FROM @table
CLOSE cur
DEALLOCATE cur