增删改查存储过程

create table Student
(
 StuID      int identity ,
 StuName    varchar (20),
 StuSex     bit,
 StuAge     int,
 StuKTime   time,
 StuJTime   time,
 StuClassID int,
)
create table StuClass
(
 ClassID    int ,
 CjassName varchar(50),
)
 
  --添加存储过程
  if exists (select  * from sysobjects where name='UP_ADDstudent')
  drop proc UP_ADDstudent
  go
  create proc UP_ADDstudent
 @StuName    varchar (20),
 @StuSex       bit,
 @StuAge      int,
 @StuKTime    time,
 @StuJTime    time,
 @StuClassID   int
 as
 insert  into Student values (@StuName,@StuSex,@StuAge,@StuKTime,@StuJTime,@StuClassID)
 go
 
 --删除存储过程
  if exists(select *from sysobjects where name ='UP_Deletestudent')
  drop proc UP_Deletestudent
  go
  create proc UP_Deletestudent
  @StuID  int
  as
  delete from Student where StuID=@StuID
  go
  --修改存储过程
  if  exists(select * from sysobjects where name ='UP_Updetestudent')
   drop proc UP_Updetestudent
   go
   create proc UP_Updetestudent
   @StuID  int,
   @StuName    varchar (20),
   @StuSex       bit,
   @StuAge      int,
   @StuKTime    time,
   @StuJTime    time,
   @StuClassID   int
   as
   update Student set StuName=@StuName,StuSex=@StuSex,StuAge=@StuAge,StuKTime=@StuKTime,StuJTime=@StuJTime,StuClassID=@StuClassID where StuID=@StuID
   go
posted @ 2018-07-30 07:44  对子、  阅读(218)  评论(0编辑  收藏  举报