PrepAway - Latest Free Exam Questions & Answers

Which three Transact-SQL statements should you use?

DRAG DROP
You use Microsoft SQL Server 2012 to develop a database that has two tables named
Div1Cust and Div2Cust.
Each table has columns named DivisionID and CustomerId . None of the rows in Div1Cust
exist in Div2Cust.
You need to write a query that meets the following requirements:
The rows in Div1Cust must be combined with the rows in Div2Cust.
The result set must have columns named Division and Customer.
Duplicates must be retained.
Which three Transact-SQL statements should you use? (To answer, move the appropriate
statements from the list of statements to the answer area and arrange them in the correct order.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:

Reference:
http://msdn.microsoft.com/en-us/library/ms180026.aspx
Reference:
http://msdn.microsoft.com/en-us/library/ms188055.aspx

12 Comments on “Which three Transact-SQL statements should you use?

  1. Markos says:

    Select DivisionID AS Division
    ,CustomerID AS Customer
    from Div1Cust

    UNION ALL

    select DivisionID AS division
    ,CustomerID AS Customer
    from Div2Cust

    –UNION won’t do it because, we have to retain duplicate
    –the other Selects Statements have the word DISTINCT in them which will
    –eliminate duplicates. so, the answer should be 5,6,9




    1



    0
  2. Mr Meat says:

    The answers are 5, 6, and 2.

    This question is tricky by design if you notice: ” None of the rows in Div1Cust
    exist in Div2Cust.”

    Therefore, you could use UNION despite “Duplicates must be retained” because there are no duplicates.

    However, UNION ALL performs better than UNION because it lacks SORT which makes it the better choice anyhow.




    0



    0

Leave a Reply