Tuesday, 16 October 2012

SQL QUERIES

 CREATE TABLE

CREATE TABLE [Employee]
(
Empid int IDENTITY (1,1) NOT NULL Primary key,
EmpNumber nvarchar (50) NOT NULL,
EmpFirstName nvarchar (150) NOT NULL,
EmpLastName nvarchar (150)  NULL,
EmpEmail nvarchar (150) NULL,
Managerid int NULL,
Departmentid Int
)

CREATE TABLE Department
(
Departmentid int IDENTITY (1,1) NOT NULL Primary key,
DepartmentName [nvarchar] (255) NOT NULL
)

SELECT * FROM Employee
SELECT * FROM Department

Insert Into Employee values ('A001','Raj','Kumar','raj@gm.com',002,10)
Insert Into Employee values ('A002','Prem','Kumar','prm@gm.com',003,20)
Insert Into Employee values ('A003','Mohan','Raj','mr@gm.com',004,30)
Insert Into Employee values ('A004','Pavan','Kalyan','pav@gm.com',005,50)
Insert Into Employee values ('A005','Mahesh','Babu','babu@gm.com',006,60)
Insert Into Employee values ('A006','Satya','Krishna','sat@gm.com',002,NULL)

SELECT * FROM Employee

insert into Department(DepartmentName)
values('Accounts')
insert into Department(DepartmentName)
values('Soft')
insert into Department(DepartmentName)
values('HR')
insert into Department(DepartmentName)
values('Technology')
insert into Department(DepartmentName)
values('Banking')
insert into Department(DepartmentName)
values('Mines')

SELECT * from Department



No comments:

Post a Comment