Home » Microsoft » MB6-886 » What should you create?
You are designing a database that will store telephone numbers. You need to ensure that only phone numbers that use a specific format are written to the database.
What should you create?
A. a CHECK constraint
B. a computed column
C. a DEFAULT constraint
D. a persisted computed column
Correct Answer: A
Explanation/Reference:
CHECK constraints enforce domain integrity by limiting the values that are accepted by one or more columns. You can create a CHECK constraint with any logical (Boolean) expression that returns TRUE or FALSE based on the logical operators. For example, the range of values for a PhoneNumber column can be limited by creating a CHECK constraint that allows for only phone numbers with the following format: xxx-xxx-xxxx.
ALTER TABLE Table1
ADD CONSTRAINT ChkPhoneNumber CHECK (PhoneNumber Like ‘[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]’);
GO