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?
- 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.