Multi-statement table-valued function with dynamic columns
Posted on 2005-04-22
In this following function example
create function fpriceAvg()
return @price Table
( code char(10),
Is there a way to declare dynamic table columns? for example in the example above code and effectivedate are the only 2 columns in the @price Table.
But my requirement is, based on what values a select statement returns, I use them as columns for a dynamic table.
eg: select distinct elements from Registration
I need to save them first ( may be using a cursor ) then I want to build a table with each row as my column heading.
systems solutions combo
company 1 10 2 4
company 2 4 7 3
Which means I had 10 people from company1 attending systems event, 2 people from company1 attended soultions event .....
So, my problem is in multi-valued user defined table, the table column names are defined once and for all, can they be dynamic like in my case ?
Is there a way this whole thing be done in sql itself ( SQL SERVER 2000)
without running back and forth between ASP.NET Pages and sql statements?