1, stored procedure------Non-parametric stored procedure
---Creating a non-parametric stored procedure
Create proc Test1
As
Begin
SELECT * FROM Info
End
---Executing stored procedures
EXEC test1
---Removing stored procedures
drop proc Test1
2, the stored procedure------ with the entry parameter
---Creating a stored procedure with a parameter
Create proc Test3
(
@id INT--Enter parameter (default is input type argument)
)
As
Begin
SELECT * from info where [email protected]
End
-----Execution of stored procedures with parameters
--a:exec Test3 1
--b:exec test3 @id =1
3, stored procedure (Procedure)-bring in and out parameters
---to create a stored procedure with a parameter entry
Create proc Test2
(
@id int,--Enter parameter
@name varchar () out,--
@age int out--out parameter "Output ID"
)
As
Begin
Select @name =name, @age =age from info where [email protected]--out of the argument @ on the left of =
End
--Declaring variables
DECLARE @name1 varchar (), @age1 int;
--Call
EXEC test2 1, @name1 out, @age1 out
--Querying out the declared variables
Select ' Name ' [email protected], ' age ' [email protected]---Specify name1 column name, age1 column name is age
SQL Server Stored Procedures