How to get Master and Slave Table data in one row using SQL Server ?

Posted by Space Cracker on Stack Overflow See other posts from Stack Overflow or by Space Cracker
Published on 2010-04-19T06:12:49Z Indexed on 2010/04/19 6:23 UTC
Read the original article Hit count: 263

Filed under:
|
|

I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has a FK from 'Employee'.

Each row in 'Employee' can have zero or many rows in 'EmployeeTypes' and I want to make an SQL Query that returns data of all Employees and each employee row should contain its related data in 'EmployeeTypes' (for example column called 'TypeID') as a comma separated list, like this:

Meco Beco ---    45   ---- 1,2,3

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005