use StudentManageDB
go
/*判断是否存在存储过程,存在就删除*/
if exists(select * from sysobjects where name = 'usp_AddStudent')
drop procedure usp_AddStudent
go
/*创建存储过程 create ..as go*/
create procedure usp_AddStudent
/*声明变量*/
@StudentName varchar(20),
@Gender char(2),
@Birthday smalldatetime,
@StudentIdNo varchar(50),
@CardNo varchar(20),
@Age int,
@PhoneNumber varchar(50),
@StudentAddress varchar(500),
@ClassId int
as
/*编写sql语句*/
insert into Students(StudentName, Gender, Birthday, StudentIdNo, CardNo, Age, PhoneNumber, StudentAddress, ClassId)
values(@StudentName, @Gender, @Birthday, @StudentIdNo, @CardNo, @Age, @PhoneNumber, @StudentAddress, @ClassId) ;select @@IDENTITY
go
网友评论