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 2008 Forums
 Transact-SQL (2008)
 Dynamic Pivot

Author  Topic 

daniel50096230
Yak Posting Veteran

99 Posts

Posted - 2013-12-12 : 02:16:30
I has the following rows in my columns:

Type_ID

Treatment_Time
Course_Description
Effective_To
Effective_From

How can I pivot them become the following columns and using the type_ID data as column name?
Treatment_Time Course_Description Effective_To Effective_From

By the way, the data in Type_ID column might be different, how can I make a dynamic pivot in order to cater this?

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-12-12 : 11:02:40
have a look at this:
http://weblogs.sqlteam.com/jeffs/archive/2005/05/02/4842.aspx

Be One with the Optimizer
TG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-12 : 11:08:00
see

http://sqlblogcasts.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

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

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -