exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 47 discussion

Actual exam question from Microsoft's 70-761
Question #: 47
Topic #: 1
[All 70-761 Questions]

Note: This question is part of a series of questions that use the same or similar answer choices. An answer choice may be correct for more than one question in the series. Each question is independent of the other questions in this series. Information and details provided in a question apply only to that question.
You have a database that contains tables named Customer_CRMSystem and Customer_HRSystem. Both tables use the following structure:

The tables include the following records:

Customer_CRMSystem -


Customer_HRSystem -

Records that contain null values for CustomerCode can be uniquely identified by CustomerName.
You need to display customers who appear in both tables and have a proper CustomerCode.
Which Transact-SQL statement should you run?

A.

B.

C.

D.

E.

Show Suggested Answer Hide Answer
Suggested Answer: A
When there are null values in the columns of the tables being joined, the null values do not match each other. The presence of null values in a column from one of the tables being joined can be returned only by using an outer join (unless the WHERE clause excludes null values).
References:
https://technet.microsoft.com/en-us/library/ms190409(v=sql.105).aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
MarcusJB
4 years, 11 months ago
The one and only correct answer A for everyone to try out: CREATE TABLE #CRM ( CustomerID INT NOT NULL, CustomerCode char(4) NULL, CustomerName varchar(50) NOT NULL ); CREATE TABLE #HR ( CustomerID INT NOT NULL, CustomerCode char(4) NULL, CustomerName varchar(50) NOT NULL ); INSERT INTO #CRM(CustomerID, CustomerCode, CustomerName) VALUES (1, 'CUS1', 'Roya'), (2, 'CUS9', 'Almundena'), (3, 'CUS4', 'Jack'), (4, NULL, 'Jane'), (5, NULL, 'Francisco'); INSERT INTO #HR(CustomerID, CustomerCode, CustomerName) VALUES (1, 'CUS1', 'Roya'), (2, 'CUS2', 'Jose'), (3, 'CUS9', 'Almundena'), (4, NULL, 'Jane'); SELECT c.CustomerCode, c.CustomerName, h.CustomerCode, h.CustomerName FROM #CRM c INNER JOIN #HR h ON c.CustomerCode = h.CustomerCode AND c.CustomerName = h.CustomerName; DROP TABLE #CRM; DROP TABLE #HR;
upvoted 4 times
stm22
4 years, 10 months ago
this is goood; does not return Jane bc her null custcode CustomerCode CustomerName CustomerCode CustomerName CUS1 Roya CUS1 Roya CUS9 Almundena CUS9 Almundena
upvoted 1 times
...
Vermonster
4 years, 4 months ago
Agree - thanks for the code. Could leave out the AND CustomerName part of the join - has nothing to do with the question asked
upvoted 1 times
...
...
Shanuramasubbu
5 years, 2 months ago
I checked it. Both A and B is correct answer
upvoted 1 times
...
Mag53
5 years, 3 months ago
A is correct. B incorrect see comment Bartek. D isncorrect: The T-SQL EXCEPT operator, added in SQL Server 2005, returns only distinct rows that appear in one set and not the other. Specifically, EXCEPT returns rows from the input set listed first in the query.
upvoted 2 times
...
fabzo
5 years, 5 months ago
Both A and B is incorrect man. The correct answer is "SELECT CustomerCode, CustomerName FROM Customer_CRMSystem EXCEPT SELECT CustomerCode, CustomerName FROM Customer_HRSystem"
upvoted 1 times
...
prakash101179
5 years, 7 months ago
I think correct answer is both A and B.
upvoted 2 times
Bartek
5 years, 7 months ago
Just A "..and have a proper CustomerCode." Intersect II keep NULL values
upvoted 26 times
...
BabyBee
4 years, 5 months ago
Only A is correct, with Intersect it reads the Nulls as equals, therefore it will return all Customers whether or not they have a proper CustomerCode.
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago