I have a query as follows
select VendorNumber,sum(EY_AmountIncl_LC)AmountIncl_LC ,SUm(EY_AmountExcl_LC)AmountExcl_LC,max(EY_datedocumented) Datedocumented
,stuff( (select distinct ','+dbo.table2.InvoiceStatus
from dbo.table2
where dbo.table2.VendorNumber = dbo.table2.VendorNumber
for xml path('')
), 1, 1, ''
) as InvoiceStatus
from dbo.table2
group by VendorNumber
How do i write the same query using temptable in sql server management studio.can anyone help?