From the course: Microsoft SQL Server 2019 Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Unique constraints

Unique constraints - SQL Server Tutorial

From the course: Microsoft SQL Server 2019 Essential Training

Start my 1-month free trial

Unique constraints

- [Narrator] There are any number of reasons why you would want to enforce values in a record to be unique from all the other records in the table. The table's primary key column is just one example of a column that needs to maintain unique values. It's probably a bad idea to have two different products with exactly the same name because that would make it confusing for customers that are trying to place an order, or maybe you want to use email addresses as a way to identify individual people when posting reviews on a recipe website. We can have SQL Server monitor the values that are being stored in our data tables and by identifying individual columns that should not allow duplicate values between records, we can have the server enforce this rule on the data. In the Landon Hotel employees table, we have a column that's storing our email addresses for the company. We can see that by right-clicking on it and choosing edit top 200 rows. Over here on the far right is the email address…

Contents