当前位置:首页 > SQL Server实用教程上机8存储过程的创建和调用(附答案)
《SQL Server实用教程》教案
实验8 存储过程的创建和调用
授课教师: 课时:2学时
? 实验目的
? 掌握存储过程的创建和调用 ?
? 实验重点
? 存储过程的创建和调用
? 实验内容
对于YGGL数据库,完成以下操作:
1、 创建存储过程,用于计算指定员工的实际收入(使用输入参数),并调用该过程。 2、 创建存储过程,查询某员工所在的部门及其收入情况,并调用该过程。
3、创建存储过程,查询员工的编号、姓名、所在部门名称、收入及支出情况(不使用任何
参数),并调用该过程。
4、创建存储过程,计算机某部门员工的平均收入(使用输入、输出参数),并调用该过程。 5、创建存储过程,计算机各部门员工的总收入,并调用该过程。
答案下页
1、 创建存储过程,用于计算指定员工的实际收入(使用输入参数),并调用该过程。 use yggl go
create proc income_infol @name char(8) as
select name,InCome
from dbo.Employees,dbo.Salary
where dbo.Employees.EmployeeID=dbo.Salary.EmployeeID and dbo.Employees.name=@name
execute income_infol '王林' 2、 创建存储过程,查询某员工所在的部门及其收入情况,并调用该过程。
use yggl go
create proc Employees_infol @name char(8) as
select DepartmentName,name,InCome
from dbo.Departments,dbo.Employees,dbo.Salary
where dbo.Departments.DepartmentID=dbo.Employees.DepartmentID and dbo.Employees.EmployeeID=dbo.Salary.EmployeeID and dbo.Employees.name=@name
execute Employees_infol '李丽' 3、 创建存储过程,查询员工的编号、姓名、所在部门名称、 收入及支出情况(不使用任何参数),并调用该过程。 create proc b as
select dbo.Departments.DepartmentID as 编号,DepartmentName as 部门名
共分享92篇相关文档