Check Constraint in MS SQL Server Last Updated : 26 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Check Constraint : It is used alongside relational operators to check whether a value satisfies the condition or not (boolean). If the condition is satisfied, the boolean expression sets to True otherwise False. The check constraint does not have a specific syntax. It is used along with the create table syntax. Syntax : Create table Marks name varchar2(30), rollnumber number primary key, marks int check (marks<=75) A table named Student is created along with the condition that marks must not be greater than 75. A user inserts a few values as shown below - Table - Marks Name Rollnumber Marks Aisha 111 60 Naina 112 73 The values are inserted as per the conditions mentioned in the create table syntax. The user tries inserting a few more values yet errors occur as shown below - Example-1: Insert into Student values('Maya', '117', '80') Output - The value results in an error as the value is greater than 75. Example-2: Insert into Student values('Maya' '111', '74') Output - An error is displayed. This is due to the primary key used for rollnumber. Primary key forbids the use of duplicates in a table. Check constraint in case of NULL : Insert into Student values('Riya', '112', 'NULL') Output - In SQL, NULL is used incase of unknown value. Therefore it is considered as False. Comment More infoAdvertise with us Next Article SQL DROP CONSTRAINT M mangalgiaishwarya2 Follow Improve Article Tags : SQL SQL-Server Similar Reads Find Duplicates in MS SQL Server Finding duplicate values in a database is a common task when managing data integrity. In SQL, several methods can be employed to identify and handle duplicate entries. In this article, We will explore two effective techniques for locating duplicates using SQL queries: the GROUP BY clause and the ROW 4 min read Introduction of MS SQL Server Data is a collection of facts and figures and we have humungous data available to the users via the internet and other sources. To manipulate the data, Structured Query Language (SQL) in short has been introduced years ago. There are different versions of SQL available in the market provided by diff 2 min read Self Join and Cross Join in MS SQL Server Prerequisite - Introduction of MS SQL Server 1. Self Join : Self-join allows us to join a table itself. It is useful when a user wants to compare the data (rows) within the same table. Syntax - select select_list from T t1 [Inner|Left] Join on T t2 on join_predicate. Here T refers to the table we us 2 min read SQL DROP CONSTRAINT In SQL, constraints are used to ensure data integrity and define rules for the data in our database tables. These rules include ensuring uniqueness, maintaining referential integrity, and validating data with conditions. By applying constraints such as primary key, foreign key, unique, and check con 4 min read SQL Server Architecture Microsoft SQL Server is a widely used relational database management system (RDBMS) that organizations around the world rely on for managing and processing their data. It provides a scalable and reliable platform for managing large volumes of data, supporting a wide range of applications from small- 5 min read How to Check if a Column Exists in a SQL Server Table? In this article, we will look at how to check if a particular column exists in a database table or not. For checking the existence of a column we need to create the table first. So, let us create a table with some columns and data. Creating table: Syntax: CREATE TABLE table_name ( column1 datatype, 2 min read Like