SQLSERVER 2000 存储过程例子
2008-12-22 11:07
351 查看
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
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
相关文章推荐
- SqlServer 2000和2005存储过程破解
- SqlServer 多条件查询 [存储过程] 经典例子结合C#的使用
- SqlServer 2000、2005分页存储过程整理第1/3页
- 批量加密SQLSERVER 2000 的存储过程
- SqlServer 多条件查询 [存储过程] 经典例子
- SqlServer 多条件查询 [存储过程] 经典例子
- SQLServer 2000中,存储过程和用户自定义函数具体的区别??
- SqlServer 多条件查询 [存储过程] 经典例子
- sqlserver中打印出某个数据库的所有存储过程代码的例子
- sqlserver 存储过程例子
- SQLServer 2000 数据库备份还原存储过程
- SQLServer 2000中,存储过程和用户自定义函数具体的区别??
- [★]SqlServer 多条件查询 [存储过程] 经典例子
- sqlserver 存储过程例子
- SQLServer 在存储过程里使用事务控制的简单小例子
- sqlserver 存储过程例子
- SqlServer 多条件查询 [存储过程] 经典例子
- sqlserver 2000 存储过程实例
- SQLServer 2000中,存储过程和用户自定义函数具体的区别??