【Windows Form 实战】学生成绩管理系统(八) 管理员模块设计3 视图和存储过程

1、班级视图

create view [Class_View]
as
select distinct(sclass)
from TableStudent;
GO

2、成绩视图

create View [S_C_Score_View]
as
select B.sname, B.snum, C.cname, C.cnum, A.score
from SC A, TableStudent B, TableCourse C
where A.snum = B.snum and A.cnum = C.cnum; 
GO

3、删除学生 存储过程

create procedure [spDeleteStudent]( @snum int )

as
begin
delete from TableStudent
where snum = @snum;

delete from SC
where snum = @snum;

delete from Login
where userID = @snum;

end
GO

4、删除教师 存储过程

create procedure [spDeleteTeacher]( @tnum int )
as
declare @cnum int
Begin

select * 
into t
from TableTeacher
where tnum = @tnum;

select @cnum = cnum from t;

if @cnum is not null
    begin
    update TableCourse  set tnum = null where cnum = @cnum;
    end

delete from TableTeacher 
where tnum = @tnum;
drop table t;

End
GO

源代码文件下载地址

你可能感兴趣的