server| Stored Procedures
CREATE TABLE test (ID int primary Key,name char (10))
INSERT into test values (1, ' test1 ')
INSERT into test values (2, ' test2 ')
INSERT into test values (3, ' test3 ')
INSERT into test values (4, ' test4 ')
1. Return result set
CREATE PROCEDURE Return_result
As
SELECT * FROM Test
EXEC Return_result
--Call
--id Name
--1 test1
--2 test2
--3 test3
--4 test4
2, input parameters and output parameters
CREATE PROCEDURE Input_output
@id int,
@name char (a) output
As
Begin
Select @name =name from test where id= @id
End
--Call
DECLARE @name char (10)
EXEC input_output 1, @name output
Select @name Name
--Output results
--name
--test1
3, return value
--Each stored procedure can return a value of Integer (integer) with a returns statement
Alter PROCEDURE Return_value
@id int
As
Begin
DECLARE @count INT--only the value of an integral type can be returned
Select @count =count (*) from test where id= @id
return @count
End
--Call
DECLARE @count char (10)
EXEC @count =return_value 1
Select @count Shuliang
--Structure
--shuliang
--1