–创建带有参数的Insert Into的存储过程
use TestDB
go
if OBJECT_ID(‘InsertStudent’,‘P’) IS NOT NULL
Drop Procedure InsertStudent
go
Create Procedure InsertStudent–添加变量
–SNO, SName, Gender, Birthday, Mobile, Email, HomeAddress, PhotoPath
@SN0 INT,
@SName CHAR(10),
@Gender CHAR(2),
@Birthday DATETIME,
@Mobile CHAR(20),
@Email CHAR(100),
@HomeAddress CHAR(100),
@PhotoPath CHAR(100)
AS
INSERT INTO Student VALUES(@SN0,@SName,@Gender,@Birthday,@Mobile,@Email,@HomeAddress)
go
–调用插入的存储过程
USE TestDB
exec TestDB.dbo.InsertStudent @SN0=95220,@SName=‘张三书’,@Gender=‘男’,@Birthday=‘1994-07-25’,@Mobile=‘13475111111’,@Email=‘1@.COM’,@HomeAddress=‘山东德州’,@PhotoPath=‘123’