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
 SQL Server Development (2000)
 Query question

Author  Topic 

memarcie
Yak Posting Veteran

91 Posts

Posted - 2008-02-05 : 09:35:47
Hello, I want to query a one to many relationship and list the many side of the relationship as columns rather than rows

Here are the two tables
Provider
prov_num int
prov_name char(50)


Prov_spec
prov_num int
specialty char(50)


I want the results to be
provider_name, specialty, specialty, specialty
Bob Smith, pediatrics, surgery, orthopedics

vs
provider_name specialty
provider_name specialty
provider_name specialty

Bob Smith, pediatrics
Bob Smith, surgery
Bob Smith, orthopedics

Can I do this?

Thanks,
Marcie

georgev
Posting Yak Master

122 Posts

Posted - 2008-02-05 : 10:02:59
You could probably achieve this with a mega set of CASE statements...
Unfortunately 2000 does not have the PIVOT function :(


George
<3Engaged!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-05 : 10:06:44
This should provide you with some ideas:-

http://www.mssqltips.com/tip.asp?tip=937
Go to Top of Page
   

- Advertisement -