hi
I have this Stored Proc and my grid is empty and no error. I have tested the proc and is returning me the result but not the grid.
How should i go about it? Thanks
I have this Stored Proc and my grid is empty and no error. I have tested the proc and is returning me the result but not the grid.
How should i go about it? Thanks
Create Proc test
as
DECLARE @query VARCHAR(4000)
DECLARE @years VARCHAR(2000)
SELECT @years = STUFF((SELECT DISTINCT
'],[' + ltrim(Dyear)
FROM Product2
ORDER BY '],[' + ltrim(Dyear)
FOR XML PATH('')
), 1, 2, '') + ']'
SET @query =
'SELECT * FROM
(
SELECT prodId,Dyear,amount
FROM Product2
)t
PIVOT (SUM(amount) FOR Dyear
IN ('+@years+')) AS pvt'
EXECUTE (@query)