Hi:
I need to return rows if exists, if not return which one of the passed value is NOT EXISTS:
DECLARE @INPUT1 BIGINT
DECLARE @INPUT2 BIGINT
DECLARE @INPUT3 BIGINT
SELECT e.Name, d.Name, c.Name
FROM Employee e
JOIN Department d ON e.DeptID = d.DeptID
JOIN City c ON e.CityID = c.CityID
WHERE
e.EmpID = @INPUT1
AND d.DeptID = @INPUT2
AND c.CityID = @INPUT3
In the above SQL, all the inputs INPUT1, INPUT2, INPUT3 are correctly passed in, returns the row. If NOT, I need to find which INPUTx is wrong. I know I could write 3 different Exists Queries to find which one is NOT exists. Is there a better approach? Thanks in advance.