I have a list of e-mail addresses, some of them are in my table, some of them are not. I want to select all e-mails from that list and whether they are in the table or not.
This Should work with all SQL versions.
SELECT E.AccessCode ,
CASE WHEN C.AccessCode IS NOT NULL THEN 'Exist'
ELSE 'Not Exist'
END AS [Status]
FROM ( SELECT '60552' AS AccessCode
UNION ALL
SELECT '80630'
UNION ALL
SELECT '1611'
UNION ALL
SELECT '0000'
) AS E
LEFT OUTER JOIN dbo.Credentials C ON E.AccessCode = c.AccessCode