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)
 Pivot, Dynamic Joins, or External Code?

Author  Topic 

profquail
Starting Member

5 Posts

Posted - 2008-11-09 : 17:08:37
I'm working on a statistical analysis project where I compare network flow between nodes. I'm trying to generate the adjacency matrix of the digraph for the network, and I'm running into a problem:

I have a piece of code that will generate one column of my desired output table given the ID of that item. However, I'm currently having to run multiple queries and join them in my external .NET code since I'm not sure how to do this dynamically.

So, given a list of all the items' ID numbers, how can I join all of these single-column tables together in SQL? Could I pivot each one, then use some kind of UNION statement to join them all, and PIVOT the result back before returning? Or would I need to write some dynamic code that would have to be run through the exec() function?

I appreciate any comments or ideas you might have...I'm pretty much stuck on this one (SQL is not my specialty).

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2008-11-09 : 18:35:35
Please post some sample data and desired output.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-09 : 23:22:12
see instructions for posting question below

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -