January 24, 2017 at 9:16 pm
January 24, 2017 at 10:28 pm
SELECT username, schoolnum, MainRole FROM test1.dbo.Table1
EXCEPT
SELECT username, schoolnum, MainRole FROM test2.dbo.Table1;
January 25, 2017 at 1:49 am
-- rows which are only in test1
SELECT username, schoolnum, MainRole,
rn = ROW_NUMBER() OVER(PARTITION BY username, schoolnum, MainRole ORDER BY (SELECT NULL))
FROM test1.dbo.Table1
EXCEPT
SELECT username, schoolnum, MainRole,
rn = ROW_NUMBER() OVER(PARTITION BY username, schoolnum, MainRole ORDER BY (SELECT NULL))
FROM test2.dbo.Table1;
and
-- rows which are only in test2
SELECT username, schoolnum, MainRole,
rn = ROW_NUMBER() OVER(PARTITION BY username, schoolnum, MainRole ORDER BY (SELECT NULL))
FROM test2.dbo.Table1
EXCEPT
SELECT username, schoolnum, MainRole,
rn = ROW_NUMBER() OVER(PARTITION BY username, schoolnum, MainRole ORDER BY (SELECT NULL))
FROM test1.dbo.Table1;
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply