January 5, 2014 at 10:46 pm
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 ????
January 5, 2014 at 11:11 pm
EXCEPT and INTERSECT were added in SQL2005.
January 5, 2014 at 11:14 pm
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
January 5, 2014 at 11:56 pm
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
)
January 6, 2014 at 7:33 am
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