I have these database structure:
Table1---
ID
Description
Table2--
ID
Table1_ID
Description
I dont know the number of data records in Table2. Example, I have data records of table 1 and 2:
ID - description
1 'des1'
And table 2:
ID - Table1_ID - description
1 1 'des2'
2 1 'des3'
I would like to query it somehow to view them like this:
Table1ID Table1_description table2_ID_2 table2_2_desc table2_ID_3 table2_2_desc
1 'des1' 1 'des2' 2 'des3'
All of the data records of table 2 will be in one line with its parent.
Would it be doable to query?
Thanks in advance.
I’ve only had to do this once before, and it was a bear. I believe there are two ways, using a PIVOT, or creating some dynamic SQL. Check out this forum for some information from people far brighter than I am:
http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/07dd8fb0-4c2c-4ed0-a6a6-4ca6a488f2d0/