Category Archives: Sql Server

SQL Server Tutorials, SQL Server Tutorials for Beginners, SQL Server Online Course, Microsoft SQL Server Learning, Microsoft Online Learing

How to create CHECK Constraint in Sql server

CHECK Constraint in Sql server CHECK constraint is to limit the value range that can be inserted in a column. If you define a CHECK constraint on a single column it allows only certain values for this column that you are defined with in check constraint. Query To create CHECK constraint:- CREATE TABLE hightech (

The database was backed up on a server running version 10.50.1600. version is incompatible with this server

The database was backed up on a server running version 10.50.1600. version is incompatible with this server When your try to restore a database which backup is taken on Sql server 2008 R2, and you will try to restore backup of that database in below version then sql server 2008 R2 then you will get

How to create FOREIGN KEY Constraint in Sql server

How to create FOREIGN KEY Constraint in Sql server A FOREIGN KEY in any table points to a PRIMARY KEY in another table. Let us Create a table Hightech:- Hightech table: Id FirstName City 1 Jai Delhi 2 Om Kolkata 3 Hari Haryana Here In table hightech Id is Primary Key of table Hightech The

How to create PRIMARY KEY constraints In Sql server

Primary Key Constraints The PRIMARY KEY constraint uniquely identifies record in a database table. Primary key column cannot have NULL values. Query:- The below following query a primary key in id column. create table account3 ( id int primary key, Firstname varchar(50), Lastname varchar(50) ) To create a PRIMARY KEY on a already created table

How to create UNIQUE constraints In Sql server

The UNIQUE constraint uniquely identifies each record in a database table. The UNIQUE constraints provide a guarantee for uniqueness for a column or set of columns. Query:- CREATE TABLE ACCOUNT2 ( P_Id int NOT NULL UNIQUE, LastName varchar(50) NOT NULL, FirstName varchar(50), Address varchar(255) ) To create a UNIQUE constraints in already created table use

How to create NOT NULL constraints In Sql server

Constraints are used to limit the type of data that can go into a table. SQL NOT NULL Constraint:- The NOT NULL constraint enforces a column to NOT accept NULL values. Query:- CREATE TABLE Account ( P_Id int NOT NULL, LastName varchar(50) NOT NULL, FirstName varchar(50) ) In this query Id and Lastname is NOT NULL