Abhilash J A

Abhilash J A

  • 525
  • 2.4k
  • 600.7k

Conversion failed converting the varchar value ',' to int

Jan 8 2016 4:24 AM
DECLARE @temp TABLE (Id varchar(MAX) NOT NULL, name varchar(MAX) NOT NULL ,itemtype varchar(50) NOT NULL );
INSERT @temp (Id,name,itemtype)
SELECT distinct STUFF((SELECT ',' + Item.Id FROM Items Item
INNER JOIN ProductDetails on Item.Id=ProductDetails.ItemsId
where Item.BrandsId in (select id from Brands) FOR XML PATH('')),1,1,'') AS ID,Item.ItemName,'Item' FROM Items AS Item
GROUP BY Item.ItemName

Select * from @temp

Answers (3)