Implementing a Data Warehouse with Microsoft SQL Server 2012/2014 — Question 30

You are a database developer of a Microsoft SQL Server 2012 database. You are designing a table that will store Customer data from different sources. The table will include a column that contains the CustomerID from the source system and a column that contains the SourceID. A sample of this data is as shown in the following table. You need to ensure that the table has no duplicate CustomerID within a SourceID. You also need to ensure that the data in the table is in the order of SourceID and then CustomerID.
Which Transact- SQL statement should you use?

Answer options

Correct answer: D

Explanation

The correct answer is D because it allows both SourceID and CustomerID to be included without duplicates by implementing a primary key constraint. Options A and B do not enforce the uniqueness of CustomerID within SourceID, while C incorrectly attempts to make SourceID the primary key, which does not meet the requirement of having unique CustomerID values for each SourceID.