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 2000 Forums
 Transact-SQL (2000)
 how create table using data to name columns?

Author  Topic 

GreeneKL
Starting Member

3 Posts

Posted - 2007-07-19 : 18:46:45
I have 3 tables: There is a many-to-many relation
between T1 and T3, and the relation data is stored
in T2.

I have user who wants query results displayed as if
in Excel spreadsheet with data from T1 as row labels,
data from T3 as column labels, and data from T2
(relationship data) displayed as "X" in corresponding
row/column cell.

Any ideas on how to accomplish this?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-19 : 19:07:36
search for CROSS TAB, PIVOT TABLE in this forum


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

Go to Top of Page

GreeneKL
Starting Member

3 Posts

Posted - 2007-07-19 : 19:45:46
Table 1: WProc
Cols: WP#
Title
Table 3: Person
Cols: ID
Name
Table 2: Assign
cols: wpID
pID

Output format (to be displayed via ASP.NET):

name1 name2 name3 name4 ...
WP1 X
WP2 X X
WP5 X X
WP18 X X
WP19
WP20
WP27
.
.
.

Where number of items in WProc and/or Person
may change at any time.
Go to Top of Page

GreeneKL
Starting Member

3 Posts

Posted - 2007-07-19 : 19:53:00
Let me try that display table again:

WorkProc | Adam | Bill | Carla | David | Emily | ...
WP1 | | x | | X | |
WP2 | X | x | x | | |
WP5 | | | | | X |
WP6 | x | | x | | x |
Go to Top of Page
   

- Advertisement -