1, 存储过程------无参存储过程
---创建无参存储过程
create proc test1
as
begin
select * from info
end
---执行存储过程
exec test1
---移除存储过程
drop proc test1
2, 存储过程------带入参
---创建带入参存储过程
create proc test3
(
@id int   --入参(默认是输入型参数)
)
as
 begin
 select * from info where id=@id
 end
-----执行带参数的存储过程
--a:exec test3 1
--b: exec test3 @id=1
3, 存储过程(Procedure)-带入参和出参
---创建带入参出 参存储过程
create proc test2
(
  @id int,--入参
  @name varchar(20) out,--出参
  @age int out--出参【出参标识output】
  )
as
begin 
select @name=name,@age=age from info where id=@id   --出参的@在=的左边
end
--声明变量
declare @name1 varchar(20),@age1 int;
--调用
exec test2 1,@name1 out,@age1 out 
--查询出声明的变量
select ‘姓名‘=@name1,‘年龄‘=@age1  ---指定name1的列名为姓名,age1的列名为年龄
原文:http://www.cnblogs.com/lschenblog/p/3953816.html