From the course: Microsoft SQL Server 2022 Essential Training

Unlock this course with a free trial

Join today to access over 24,000 courses taught by industry experts.

Unique constraints

Unique constraints

- [Instructor] There are any number of reasons why you would want to enforce values in a record to be unique from all other records in the same 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 table, and by identifying individual columns that should not allow duplicate values between records, we can have the server enforce this rule on the data. Let's take a look inside of the products table for the Red30Tech database. Going to expand it open here and then expand the columns folder. In this table, we…

Contents