国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

sql server 2000 存儲過程的類型和實例

2024-08-31 00:49:10
字體:
來源:轉載
供稿:網友
中國最大的web開發資源網站及技術社區,

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 [email protected]
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 [email protected]
return @count
end


--調用
declare @count char(10)
exec @count=return_value 1
select @count shuliang
--結構
--shuliang
--1
 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨玉县| 罗甸县| 崇信县| 岳阳县| 彭州市| 新乡县| 黎城县| 赤水市| 巴楚县| 泾川县| 诏安县| 宣威市| 太保市| 兴宁市| 开江县| 文昌市| 章丘市| 寿宁县| 宜兰县| 鲁甸县| 抚顺市| 延边| 陆河县| 彩票| 镇远县| 方山县| 郴州市| 双辽市| 车致| 六安市| 盐亭县| 武清区| 铁岭市| 蒙城县| 石楼县| 舟曲县| 封丘县| 屏边| 岑巩县| 佳木斯市| 定州市|