I have a table of equipment, a table of customers and a sparse table of equipment and customers. I want to produce a query that returns a 1 if the equipment/Customer table record exists and a 0 if it doesn't for each customer. There are only a small number of customers in this problem, so what I want back should look like this:
EquipmentID Cust1 Cust2 Cust3
1234101
1357010
2234100
I can use a Cross Join to get a master list of possible records, but that returns the information in rows. I want to see it in columns, but the PIVOT function requires that I name the columns first. What I need is for the column names (Cust1, Cust2...) to be dynamic.