Microsoft

DP-800 practice question 12

Developing AI-Enabled Database Solutions · free question 12 of 20

Question

You have an Azure SQL database that contains a table named Rooms. Rooms was created by using the following Transact-SQL statement. You discover that some records in the Rooms table contain NULL values for the Owner field. You need to ensure that all future records have a value for the Owner field. What should you add?
CREATE TABLE Rooms with RoomID int PRIMARY KEY, Owner nvarchar(100) and Capacity int.
  • A. a foreign key
  • B. a check constraint Correct
  • C. a nonclustered index
  • D. a unique constraint

Explanation

A check constraint limits the values a column accepts, so CHECK (Owner IS NOT NULL) rejects any new row without an Owner. It can be added WITH NOCHECK so that the existing rows with NULL do not block it. A foreign key still allows NULL and only validates values that are present. A unique constraint also allows a NULL value, and a nonclustered index does not enforce any value rule.

Practice the whole free set

Answer all 20 free DP-800 questions with instant feedback, or unlock all 55 questions with Learn and Exam modes.