This is basically to return all the records from one result set where there is no matching in another table. This looks very similar to “Outer join” but join does horizontally and EXCEPT does vertically.
Let’s look at the example:
SELECT EmployeeID,Name,Salary,DOJ from Employee
EXCEPT
SELECT EmployeeID,Name,Salary,DOJ from Employee_HIST
With the above query we are fetching only the records which are in Employee but not in Employee_HIST.
Thursday, August 7, 2008
Except in SQL Server
Labels:
SQL,
SQL Database,
SQL Server,
SQL Server Tips,
T-SQL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment