Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

create database testDB2

use testDB2
create table tblPerson5
(
ID int primary key,
Name nvarchar(50) NOT NULL,
Age int,
Salary int,
City nvarchar(50),
Gender nvarchar(10)
)

insert into tblPerson5


values (1, 'Ahmad', 20, 25000, 'BWN', 'Male')

insert into tblPerson5


values (2, 'Asma', 21, 50000, 'CTN', 'Female')

insert into tblPerson5


values (3, 'Majid', 22, 125000, 'BWN', 'Male')

insert into tblPerson5


values (4, 'Naheed', 19, 5000, 'BWN', 'Female')

insert into tblPerson5


values (5, 'Shamrez', 22, 30000, 'LHR', 'Male')

insert into tblPerson5


values (6, 'Maria', 24, 26000, 'KHI', 'Female')

insert into tblPerson5


values (9, 'Amir', 27, 25000, 'KHI', 'Male')

SET IDENTITY_INSERT tblPerson4 OFF

DBCC CHECKIDENT(tblPerson4,RESEED, 100)

delete from tblPerson4 where ID != 2

select * from tblPerson5


where Name LIKE '[^MA]%'

Alter table tblPerson


Add Constraint DF_tblPerson_Gender_Others
Default 'Others' For Gender

Alter table tblPerson3


Add Constraint CK_tblPerson3_Age_0_100
check (Age >=0 AND Age <=100)

You might also like