how to return dynamic column name in stored procedure?
Posted on 2013-01-07
in my stored procedure, i group the result set to return multiple groups like 'Sheet1', 'Sheet2'
Here is my the grouping return in my SP:
select [Sheet + @loop] = 'Sheet' + Convert(varchar(10), @loop), * from @Result result
WHERE result.State = (Select top 1 State from @Group where RowID = @loop) AND
SELECT @loop = @loop + 1
How can i make the first column name as 'Sheet1', 'Sheet2', 'Sheet3', etc.
I know my syntax is wrong as [Sheet + @loop], but just want to give u some idea