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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Dynamic Pivot
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

daniel50096230
Yak Posting Veteran

Malaysia
99 Posts

Posted - 12/12/2013 :  02:16:30  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6065 Posts

Posted - 12/12/2013 :  11:02:40  Show Profile  Reply with Quote
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

India
52326 Posts

Posted - 12/12/2013 :  11:08:00  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000