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)
 Pivoting Question

Author  Topic 

dewacorp.alliances

452 Posts

Posted - 2009-10-18 : 04:00:00
I have a table strcuture (golf score card) as follow:

HoleID int
CourseID int
Par INT
Distance INT
LowIndex INT
HighIndex INT
Sequence INT (representing the sequence of the hole: 1, 2, 3, ... 18)


This course has 18 holes.

I want to pivoting into:

Hole,      1, 2, 3, ... 18
Par, X, X, X, ... X
Distance, Y, Y, Y, ... Y
LowIndex, Z, Z, Z, ... Z
HighIndex, A, A, A, ... A

I can achieve this by using cursor but is there any better way?

dewacorp.alliances

452 Posts

Posted - 2009-10-18 : 04:46:28
Never mind guys ... I worked out using combination of PIVOT for each element (Par, Distance, LowIndex, HighIndex) and then UNION for all of them

Go to Top of Page
   

- Advertisement -