C#笔记之存储过程的简单创建
2020-06-15 本文已影响0人
没错就是豪哥灬
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