T_SQL语句创建存储过程

Class表如下:

****************************************************************

ClassID(PK ,int ,not null)

ClassName(varchar(50), not null)

GradeID(Fk,int ,null)

 

****************************************************************

存储过程如下:

--Class插入语句
create proc InsertClass
 @ClassName varchar(50),
 @GradeID int
as
 insert into Class(ClassName,GradeID) values (@ClassName,@GradeID)
select @@identity
go

--Class删除语句
create proc DeleteClass
as
 delete from Class
go

--Class修改语句
create proc UpdateClass
 @ClassName varchar(50),
 @GradeID int,
 @ClassId int
as
 update Class set ClassName=@ClassName,GradeID=@GradeID where ClassId=@ClassId
go

--根据班级Id查询班级信息
create proc SelectClass
 @ClassId int
as
 select A.*,B.GradeName as GradeIDName from Class A,Grade B
where ClassId=@ClassId
go

--查询所有班级信息
create proc SelectClassesALL
as
 select * from Class
go

你可能感兴趣的:(T_SQL语句创建存储过程)