SQL Server: Check Constraint

Level : Beginner
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:25:00

Lab Details

Description

CHECK is a constraint that is placed on one or more columns. It specifies that the values must satisfy certain conditions. This ensures that invalid data does not enter the column. Adding an invalid value to a CHECK column will cause an error.

In this lab, you will learn how to add a Check Constraint to a table in SQL Server.


Based on this Customer and Supplier Schema, generate the solutions to the respective queries listed below:

  1. Create a customer table and the ‘Status’ column in it only accepts Active and Inactive values.
  2. Add a CHECK Constraint to the ‘Country’ Column in an existing Customer table.
  3. Remove a CHECK Constraint from the Customer table.
  4. Create a ‘Measurement’ table and CHECK Constraint checks two column values concurrently. (Misc)

Lab Objective

Upon completion of this lab, you will be able to:

  • Gain Hands-On Experience on SQL Server CHECK Constraint.

Prerequisites

  • You should have a conceptual understanding of Constraints.
  • You must have SQL Server Installed on your systems.
Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this