以下代码创建了一个数据库增加的存储过程
USE [UserInfo]
GO
/****** Object: StoredProcedure [dbo].[userinfo_add] Script Date: 2018/12/25 14:28:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[userinfo_add]
-- Add the parameters for the stored procedure here
@name NVARCHAR(50) =name11,
@sex NVARCHAR(50) =男,
@age INT =26
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
--SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO people(Name,Sex,Age)
VALUES (@name,@sex,@age)
END
其中@name,@sex,@age是传入的参数,Name,Sex,Age是表people的列名
执行存储过程:
新建查询
EXEC userinfo_add