Create procedure CancelCourse
(
@StudentID int,
@CourseID int,
@ElectiveID int output
)
as
select
@ElectiveID=ElectiveID
from
Elective
where
@StudentID=StudentID
and
@CourseID=CourseID
delete from
Elective
where
(
@StudentID=StudentID
and
@CourseID=CourseID
)
GO
尽量解释清楚点 我刚学的
(
@StudentID int,
@CourseID int,
@ElectiveID int output
)
as
select
@ElectiveID=ElectiveID
from
Elective
where
@StudentID=StudentID
and
@CourseID=CourseID
delete from
Elective
where
(
@StudentID=StudentID
and
@CourseID=CourseID
)
GO
尽量解释清楚点 我刚学的
解决方案 »
- 字段中的“/"
- 恢复数据库备份的时候,特别慢
- [求语句]如何将数据库中名字为tablename*的所有表名找出来?
- 可以用一条语句得到每个月的记录条数吗?
- 只有小弟我才没有能力拿的分,大家快来抢
- SQL Server 2005 存储过程调用另一个存储过程,能否操作其返回的结果集???????
- 排序问题?
- 我用ADO连接SQL Server2000为什么总显示登录失败?
- 我的程序想要控制SQLServer自动定时备份,给我些头绪!注:我的程序不能实时运行,能不能通过发送什么命令给SQLServer,让它自动完成定时
- 增加字段后插入速度变慢!大家帮我
- 如何求某一列数值的和?
- 怎么把表添加到SQL SERVER 2000里
--创建存储过程名称为CancelCourse
(
@StudentID int,
@CourseID int,
@ElectiveID int output
--定义三个变量,其中两了是输入的,一个是输出的
)
as
--存储过程代码
select
@ElectiveID=ElectiveID
from
Elective
where
@StudentID=StudentID
and
@CourseID=CourseID
delete from
Elective
where
(
@StudentID=StudentID
and
@CourseID=CourseID
)
GO--执行
我补充一下
该过程就是选修课退选过程
select
@ElectiveID=ElectiveID
from
Elective
where
@StudentID=StudentID
and
@CourseID=CourseID
以上是从Elective表中找出符合输入的StudentID和CourseID的条目然后将相应条目的Elective字段值赋予@ElectiveIDdelete from
Elective
where
(
@StudentID=StudentID
and
@CourseID=CourseID
)
从Elective表中删除对应StudentID和CourseID的记录
选修课就被取消了