Work around's in SQL
While working on one of data retrival process we felt a need to use INTERSECT & MINUS operators of Oracle in SQL Server. We didn't found any direct equivalence for those keywords but we got one workaround.
INTERSECT:Oracle
SELECT EmployeeID FROM Employee WHERE......
INTERSECT
SELECT EmployeeID FROM Order
SQL(work around)SELECT OrderID, OrderDate FROM Orders O WHERE EXISTS(SELECT 1 FROM Employees E WHERE O.EmployeeID = E.EmployeeID)
MINUS:Oracle
SELECT OrderID FROM Employee WHERE......
MINUS
SELECT OrderID FROM Order
SQL (work around)SELECT OrderID, OrderDate FROM Orders O WHERE NOT EXISTS(SELECT 1 FROM Employees E WHERE O.EmployeeID = E.EmployeeID)
While working on one of data retrival process we felt a need to use INTERSECT & MINUS operators of Oracle in SQL Server. We didn't found any direct equivalence for those keywords but we got one workaround.
INTERSECT:Oracle
SELECT EmployeeID FROM Employee WHERE......
INTERSECT
SELECT EmployeeID FROM Order
SQL(work around)SELECT OrderID, OrderDate FROM Orders O WHERE EXISTS(SELECT 1 FROM Employees E WHERE O.EmployeeID = E.EmployeeID)
MINUS:Oracle
SELECT OrderID FROM Employee WHERE......
MINUS
SELECT OrderID FROM Order
SQL (work around)SELECT OrderID, OrderDate FROM Orders O WHERE NOT EXISTS(SELECT 1 FROM Employees E WHERE O.EmployeeID = E.EmployeeID)