Difference between the INTERSECT and EXCEPT operators

Can you explain the difference between the INTERSECT and EXCEPT operators?

INTERSECT returns data value common to BOTH queries (queries on the left and right side of the operand). On the other hand, EXCEPT returns the distinct data value from the left query (query on left side of the operand) which does not exist in the right query (query on the right side of the operand).
Example:
Table 1 has values: jim, tony, john
Table 2 has values: Tony, jason, marie
Except query:
SELECT COL1 FROM Tbl_1 EXCEPT SELECT COL1 FROM tbl_2
GO
This will return Jim, John

Can you explain the difference between the INTERSECT and EXCEPT operators?

EXCEPT: Two query expressions are evaluated and the difference between the results will be returned by EXCEPT operator. The result set will have rows returned from the first set of rows except the rows those are also returned from the second set of rows.

INTERSECT: The result of two queries is evaluated and returns the rows which are common to each.
What is the new error handling technique in SQL Server 2005?
SQL Server 2005 introduces a new exception handling paradigm using TRY / CATCH blocks in T-SQL. The errors are well trapped in the try block and the execution is transferred to the catch block......
What exactly is SQL Server 2005 Service Broker? - Data warehousing
Servive brokers allow build applications in which independent components work together to accomplish a task......
Explain the Service Broker components - Data warehousing
Service broker components help build applications in which independent components work together to accomplish a task.....
Post your comment