sql server 2000 存储过程的类型和实例
2006-12-28 14:44
561 查看
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、返回结果集
create procedure return_result
as
select * from test
exec return_result
--调用
--id name
--1 test1
--2 test2
--3 test3
--4 test4
2、输入参数和输出参数
create procedure input_output
@id int,
@name char(10) output
as
begin
select @name=name from test where id=@id
end
--调用
declare @name char(10)
exec input_output 1,@name output
select @name name
--输出结果
--name
--test1
3、返回值
--每个存储过程都可以以一个return语句返回一个整型(integer)的值
alter procedure return_value
@id int
as
begin
declare @count int --只能返回整型的值
select @count=count(*) from test where id=@id
return @count
end
--调用
declare @count char(10)
exec @count=return_value 1
select @count shuliang
--结构
--shuliang
--1
相关文章推荐
- SQL SERVER 2000 连接ORCLE数据库 (加了一个存储过程的实例)
- SQL Server :VB中动态调用含DateTime类型存储过程的方法
- sql server存储过程实例:统计一段时间内各连续ID的价格合计
- VC6.0通过ADO调用SQL Server 2000的存储过程出现参数过多的问题
- sql server 2005分页存储过程和sql server 2000分页存储过程
- ASP调用sql server 存储过程详解-附带实例-
- 快速玩转 SQL Server中带 表类型参数 的存储过程 —附源码
- SQL SERVER 存储过程实例
- SQL Server 2000通用分页查询存储过程(可指定返回字段,查询条件)
- SQL Server 存储过程语法及实例
- SQL Server 2000数据库存储过程的调用(VB)
- 在存储过程中编写正确的事务处理代码(SQL Server 2000 & 2005)
- sql server 2000 单主键高效分页存储过程
- JSP调用SQL server 2000存储过程
- sql server 的存储过程实例
- SQL Server 2000/2005检测存储过程名是否存在,存在删除
- Sql Server 存储过程实例讲解
- SQL Server中使用表类型参数批量添加和修改的存储过程
- 在存储过程中编写正确的事务处理代码(SQL Server 2000 & 2005)
- SQL Server 存储过程分页大全(2005,2000)