SELECT *
FROM Activities a
INNER JOIN Cases AS b ON a.CaseId = b.Id
INNER JOIN Atts AS d ON d.CaseId = b.Id
LEFT JOIN Users AS c ON a.responsible = c.UserId
INNER JOIN Users AS e ON b.AlienId = e.UserId
WHERE a.FirmId = 9
AND ( a.ActType = 'TASK'
OR a.ActType = 'DEADLINE'
)
AND a.Complete = '0'
AND a.DateInitiated < LEFT(DATEADD(DAY, 0, GETDATE()), 12)
AND b.Archived <> 1
AND c.UserId is null
ORDER BY c.MailStr ASC;
DELETE
FROM Activities a
INNER JOIN Cases AS b ON a.CaseId = b.Id
INNER JOIN Atts AS d ON d.CaseId = b.Id
LEFT JOIN Users AS c ON a.responsible = c.UserId
INNER JOIN Users AS e ON b.AlienId = e.UserId
WHERE a.FirmId = 9
AND ( a.ActType = 'TASK'
OR a.ActType = 'DEADLINE'
)
AND a.Complete = '0'
AND a.DateInitiated < LEFT(DATEADD(DAY, 0, GETDATE()), 12)
AND b.Archived <> 1
AND c.UserId is null
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'a'.
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.