To add a primary key constraint to a table as NONCLUSTERED and NOT ENFORCED, which T-SQL statement is correct?

Study for the Fabric Analytics Engineer Associate Test. Engage with interactive flashcards and multiple-choice questions complete with hints and explanations to solidify your understanding. Get thoroughly prepared for your certification exam!

Multiple Choice

To add a primary key constraint to a table as NONCLUSTERED and NOT ENFORCED, which T-SQL statement is correct?

Explanation:
In SQL Server, you can control both the index type for a primary key and whether the constraint is enforced. A nonclustered primary key uses a nonclustered unique index, and NOT ENFORCED defines the constraint but tells the engine not to enforce it on data (existing or new) until enforcement is turned on again. The statement that matches both requirements is: ALTER TABLE dbo.Dim_Customer ADD CONSTRAINT PK_Dim_Customer PRIMARY KEY NONCLUSTERED (CustomerKey) NOT ENFORCED. This creates a nonclustered primary key constraint that is defined but not enforced. The alternatives would either enforce the constraint, or use a clustered index for the primary key, which isn’t what’s asked.

In SQL Server, you can control both the index type for a primary key and whether the constraint is enforced. A nonclustered primary key uses a nonclustered unique index, and NOT ENFORCED defines the constraint but tells the engine not to enforce it on data (existing or new) until enforcement is turned on again. The statement that matches both requirements is: ALTER TABLE dbo.Dim_Customer ADD CONSTRAINT PK_Dim_Customer PRIMARY KEY NONCLUSTERED (CustomerKey) NOT ENFORCED. This creates a nonclustered primary key constraint that is defined but not enforced. The alternatives would either enforce the constraint, or use a clustered index for the primary key, which isn’t what’s asked.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy