Intersect and Except Not worked on sqlserver 2000

  • Dear Friends,

    I m trying to learn on set operators in MSSQL,so i created two tables

    CREATE TABLE Students2000(

    Name VARCHAR(15),

    TotalMark INT)

    CREATE TABLE Students2005(

    Name VARCHAR(15),

    TotalMark INT)

    INSERT INTO Students2000 VALUES('Robert',1063)

    INSERT INTO Students2000 VALUES('John',1070)

    INSERT INTO Students2000 VALUES('Rose',1032)

    INSERT INTO Students2000 VALUES('Abel',1002)

    INSERT INTO Students2005 VALUES('Robert',1063)

    INSERT INTO Students2005 VALUES('Rose',1032)

    INSERT INTO Students2005 VALUES('Boss',1086)

    INSERT INTO Students2005 VALUES('Marry',1034)

    when i tried to make intersect and except in above table its not working showing error on it

    select * from Students2000

    except

    select * from Students2005

    ERROR:Incorrect syntax near the keyword 'EXCEPT'.

    What was the problem here ????

  • EXCEPT and INTERSECT were added in SQL2005.

  • Thx Friend,

    If suppose i m expect EXCEPT o/p in sql server 2000 how to that?

    or any other replacements are there for INTERSECT & EXCEPT

  • you can do this

    SELECT *

    FROM Students2000 a

    WHERE NOT EXISTS ( SELECT 1

    From Students2005 b

    Where b.Name = a.Name

    AND b.TotalMark = a.TotalMark

    )

  • INTERSECT should be equivalent to INNER JOIN, as any non-matching values fall out of the result.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply