Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Dynamically creating tables and columns

Author  Topic 

karthikeyan.marlen
Starting Member

16 Posts

Posted - 2011-11-28 : 07:01:27
Hi

I want to create a table with columns dynamically using storedprocedure

and output want to be like

sno name subject1 mark1 subject2 mark2 subject3 mark3

where counting(that is 1 to 3) will be given at inputparameter to

storedprocedure

pls provide me a solution for this

Thanks in advance


karthikeyan

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-28 : 07:22:28
see

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql-programmers
Posting Yak Master

190 Posts

Posted - 2011-11-28 : 07:26:33
I have a blog article to maybe assist you with your question,

http://www.sql-programmers.com/Blog/tabid/153/EntryId/6/Using-PIVOT-and-UNPIVOT.aspx

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-28 : 07:28:33
quote:
Originally posted by sql-programmers

I have a blog article to maybe assist you with your question,

http://www.sql-programmers.com/Blog/tabid/153/EntryId/6/Using-PIVOT-and-UNPIVOT.aspx

SQL Server Programmers and Consultants
http://www.sql-programmers.com/


you need to apply multiple PIVOTs in above scenario if at all you're using it
So I think better method might be what is in Madhis link above

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -