use master
go
if exists (select * from sysdatabases where name='TB0612156')
drop database TB0612156
go
create database TB0612156
go
use TB0612156
go
create table Department
(
DepartID int identity(1,1)primary key, --部门编号
DepartName varchar(20), --部门名称
DepartTel varchar(20) --部门电话
)
go
--添加部门信息的存储过程
create proc AddDepartment_Proc
(
@DepartName varchar(20),
@DepartTel varchar(20)
)
as
begin
insert into Department values(@DepartName,@DepartTel)
end
go
--修改部门信息的存储过程
create proc UpdateDepartment_Proc
(
@DepartID int,
@DepartName varchar(20),
@DepartTel varchar(20)
)
as
begin
Update Department set DepartName=@DepartName,DepartTel=@DepartTel where DepartID=@DepartID
end
go
--删除部门信息的存储过程
create proc DeleteDepartment_Proc
(
@DepartID int
)
as
begin
delete from Department where DepartID=@DepartID
end
go
--查询所有部门信息的存储过程
create proc SelectDepartmentAll_proc
as
begin
select * from Department
end
go
------------------------员工信息
create table Employee
(
EmpID int identity(1001,1) primary key, --职员编号
DepartID int, --部门编号[来自于部门表Department的部门编号]
EmpName varchar(20), --职员姓名
EmpAge int, --职员年龄
EmpSex bit, --职员性别
EmpState varchar(100) --职员职位
)
go
--添加员工信息的存储过程
--修改员工信息的存储过程
--删除员工信息的存储过程
--精确查询员工信息的存储过程[按照部门信息]