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)
 need help on pivot urgent

Author  Topic 

shaik.zakeer
Posting Yak Master

117 Posts

Posted - 2009-10-26 : 03:28:24
i have values in a table like this

col1 col2 col3 date
a - - 10/02/2009
b c - 10/05/2009
- d e 10/16/2009
- - f 10/20/2009

i want the result like this

item 10/02/2009 10/05/2009 10/16/2009 10/20/2009
_____________________________________________________________________
col1 a b - -

col2 - c d -

col3 - - e f

please help me how can i do this.

Note: i don't know how many date's are going to come.

help needed very urgent



Thanks

Jack

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-26 : 04:30:42
looks like you will needed to use PIVOT operator with Dynamic SQL.

Check out PIVOT in the Books OnLine and for Dynamic SQL, refer to The Curse and Blessings of Dynamic SQL


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

shaik.zakeer
Posting Yak Master

117 Posts

Posted - 2009-10-26 : 06:56:33
not able to understood how to do this...

can anyone give me script for this....
its very urgent....

help me

Thanks

Jack
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-26 : 07:03:56
also check out this http://sqlblogcasts.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -