I have a query that gathers all information on our projects. (tProjects). All contacts working on the project are linked to this table from tContacts by project many to many tables. (ie: tProjects linked to tProjectProducers which is linked to tContacts. The same for tProjects -> tProjectDirectors -> tContacts.)
Currently I'm running a query that returns all linked contact fields. Hence, I can have hundreds of records for ONE project which means I have to do the sorting in my report, which is slow.
What if I were to run a sub-query for each contact type, instead of a join, and then loop through the contacts on that project and create a comma separated varchar variable to return in the query as "ProjectProducers", "ProjectDirectors", etc. so that I can just insert the value from the query into a field on the report?
Since there are 10 or so sub-queries that would have to be run, I'm wondering if for each contact type, looping through the few records to create a variable would be efficient.
As you've probably deduced by now, I'm new to T-SQL and SQL Server. I've been an Access programmer for some time now, so I'm not as efficient in SQL Server as I'd like to be and I may be on the wrong path in this approach anyway, so your help is appreciated!
Currently I'm running a query that returns all linked contact fields. Hence, I can have hundreds of records for ONE project which means I have to do the sorting in my report, which is slow.
What if I were to run a sub-query for each contact type, instead of a join, and then loop through the contacts on that project and create a comma separated varchar variable to return in the query as "ProjectProducers", "ProjectDirectors", etc. so that I can just insert the value from the query into a field on the report?
Since there are 10 or so sub-queries that would have to be run, I'm wondering if for each contact type, looping through the few records to create a variable would be efficient.
As you've probably deduced by now, I'm new to T-SQL and SQL Server. I've been an Access programmer for some time now, so I'm not as efficient in SQL Server as I'd like to be and I may be on the wrong path in this approach anyway, so your help is appreciated!