上图
------解决方案--------------------
create table Goods
(
GoodsId varchar(50),
GoodsName varchar(50)
)
Insert into Goods values('1','朝花夕拾')
Insert into Goods values('2','永州八记')
Insert into Goods values('3','呐喊')
Insert into Goods values('4','镜花缘')
Insert into Goods values('5','桃花扇')
SELECT InventId,
GoodsName=(SELECT stuff( (select ';'+ltrim(GoodsName) from Goods g
where charindex(CONVERT(VARCHAR,g.GoodsId)+';',i.GoodsId+';')>0 for xml path('') ),1,1,''))
FROM Inventory i