USE INTERSECT IN SQL SERVER

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 582  View(s)
Ratings:
Rate this:
We want to use Intersect in sql server.how will do this please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: Use Intersect in sql server

    Intersect: The intersect statement is used to fetch the common records between the tables. Here we have two tables. Both tables have similar kinds of records.

    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:

     

    INTERSECT QUERY :

     

    SELECT ProductId,ProductName,ManufacturedBy FROM ProductStock

    INTERSECT

    SELECT ProductId,ProductName,ManufacturedBy FROM ProductOrder

    Result :

     

      Modified On Mar-08-2016 10:31:15 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!