Friday, September 25, 2009

Except Operator in SQL Server 2005

EXCEPT operator will be used to determine which rows exist only in the left table of the query,TableA, and not in TableB:

SELECT EmployeeID,Name FROM TableA

EXCEPT

SELECT EmployeeID,Name FROM TableB

This Returns:

Emploteeid Name

-------------------- ------------------------------

1 Nancy

2 Andy

3 Janet

4 Margaret

5 Steven

This query have very less execution plan compare to not in operator.

No comments:

Post a Comment