Declare @Result as varchar(max)='';
SELECT DISTINCT @Result = dbo.MaterialTypes.Title + ', '+ @Result
FROM dbo.TempId LEFT OUTER JOIN
dbo.ProductMaterials ON dbo.ProductMaterials.Product = dbo.TempId.Id LEFT OUTER JOIN
dbo.MaterialTypes ON dbo.ProductMaterials.MaterialType = dbo.MaterialTypes.Id LEFT OUTER JOIN
dbo.Products ON dbo.Products.Id = dbo.TempId.Id
WHERE (dbo.Products.IsCollection = 1)
SELECT DISTINCT dbo.TempId.Id AS MaterialCollection_id, @Result
FROM dbo.TempId LEFT OUTER JOIN
dbo.ProductMaterials ON dbo.ProductMaterials.Product = dbo.TempId.Id LEFT OUTER JOIN
dbo.MaterialTypes ON dbo.ProductMaterials.MaterialType = dbo.MaterialTypes.Id LEFT OUTER JOIN
dbo.Products ON dbo.Products.Id = dbo.TempId.Id
WHERE (dbo.Products.IsCollection = 1)
このクエリは機能しますが、このクエリに基づいてビューを作成できません。助けてください!