I am struggling with a t-ql query. Here are the 3 tables I am refrencing,
I am struggling with a t-ql query. Here are the 3 tables I am refrencing, I need a query that will give me the following results,Where the field is Marked True if there is a corresponding record in the Tracker table that has the Complete column marked True.Servername L&S Shutdown L&S Mon Off L&S Backup Execserver1 TRUE NULL NULLserver2 TRUE NULL NULLserver3 TRUE NULL NULLserver4 NULL NULL NULLserver5 NULL NULL NULL The following query gets me close but it does not include the Complete status (True or False) in the results.SET NOCOUNT ONDECLARE @CMD VARCHAR(1000) --Direct to output SELECT @CMD=ISNULL(@CMD+','+'['+Name+']','['+Name+']') FROM dbo.Task WHERE ProjectID=7 GROUP BY NameORDER BY NameSELECT @CMD=' SELECT * FROM (SELECT A.Name AS ServerName,T.Name AS TaskName FROM dbo.Asset A JOIN (SELECT ProjectID,Name FROM dbo.Task WHERE ProjectID=7 GROUP BY ProjectID,Name) T ON A.ProjectID=T.ProjectID) T PIVOT (COUNT(TaskName) FOR TaskName IN ('+@CMD+')) P ORDER BY ServerName'PRINT 'Here is the direct query result:'PRINT ''EXEC(@CMD) Results of above query,ServerName Resync Shutdown Signoff Startup TastApps Server1 1 1 1 1 1 Server2 1 1 1 1 1 Server3 1 1 1 1 1 Server4 1 1 1 1 1 Server5 1 1 1 1 1 TIm