My Final Table is #Example and in that table m adding Addition of 5 Columns but its not working Properly..???
declare @columnheader varchar(max)
Select @columnheader = COALESCE(@columnheader + ',isnull([' + cast(@FieldName as varchar) + '],0)','isnull([' + cast(@FieldName as varchar)+ '],0)')
DECLARE @query VARCHAR(max)
SET @query = '
SELECT * into fianltable
SUM(Col1+ Col2+ Col3+ Col4 + Col5)
----In that line error will occur
----If m can change this line n taking only SUM(Col1) then its Works, but i want addition of
---- FIVE columns
IN (' + @columnheader + ')
AS p order by ' + @columnheader + '
View Complete Post