EXCEPT: The EXCEPT operator returns all distinct the rows that are present in the result set of the first query, but not in the result set of the second query. It means it returns the difference between the two result sets.
CREATE TABLE ProductStock
(
ProductId INT PRIMARY KEY IDENTITY(1,1),
ProductName VARCHAR(100),
ManufacturedBy VARCHAR(100),
StockQty BIGINT,
LastUpdated date
)
Go
CREATE TABLE ProductOrder
(
OrderId INT PRIMARY KEY IDENTITY(1,1),
ProductId int,
ProductName VARCHAR(100),
ManufacturedBy VARCHAR(100),
OrderQty BIGINT,
OrderDate date
)
ProductStock:
ProductOrder:
EXCEPT QUERY:
SELECT ProductId,ProductName,ManufacturedBy FROM ProductStock
EXCEPT
SELECT ProductId,ProductName,ManufacturedBy FROM ProductOrder
Result :
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
EXCEPT: The EXCEPT operator returns all distinct the rows that are present in the result set of the first query, but not in the result set of the second query. It means it returns the difference between the two result sets.
CREATE TABLE ProductStock
(
ProductId INT PRIMARY KEY IDENTITY(1,1),
ProductName VARCHAR(100),
ManufacturedBy VARCHAR(100),
StockQty BIGINT,
LastUpdated date
)
Go
CREATE TABLE ProductOrder
(
OrderId INT PRIMARY KEY IDENTITY(1,1),
ProductId int,
ProductName VARCHAR(100),
ManufacturedBy VARCHAR(100),
OrderQty BIGINT,
OrderDate date
)