This works for me:declare @p table(ID int, Name varchar(20), Color varchar(20), Size char(1))insert into @p(id, Name, Color, Size) values--PRODUCT TABLE--------------------ID NAME COLOR SIZE(1,'Tshirt','Red ', 'M'),(2,'Shoes ','Blue', 'M')declare @i table(id int, product_id int, image_name varchar(20))insert into @i (id, product_id, image_name) values--PRODUCT_IMAGES TABLE-----------------------------ID PRODUCT_ID IMAGE_NAME(1, 1, 'abc.jpg'),(2, 1, 'xyz.jpg'),(3, 1, 'aaa.jpg')select id, [1],[2],[3]from( select p.id, i.image_name, i.id as image_id from @p p join @i i on i.product_id = p.id) srcpivot (max(image_name) for image_id in ([1],[2],[3])) pvt