Trying to fix someone else's code. The NOT IN kills performance. I took it out and replaced with Not Exists and I'm getting different results. The commented out not in is just above my not exists. Anyone see anything stupid I'm doing here?
IF @ProcessComplete = 1
BEGIN
-- PRINT 'Group-Complete'
INSERT INTO @ProcessIDTable
SELECT DISTINCT(ProcessID)
FROM vPortalInbox
WHERE GroupUserIDs LIKE '%,' + CAST(@UserID AS VARCHAR(MAX)) + ',%'
AND StepOwnerID IS NULL
--AND ProcessID NOT IN (SELECT ProcessID FROM @ProcessIDTable)
And not exists (SELECT ProcessID FROM @ProcessIDTable)