函数返回多个值
来源:互联网 发布:php pack 16进制 编辑:程序博客网 时间:2024/04/30 07:46
USE [Learnmanager]
GO
/****** Object: UserDefinedFunction [dbo].[getCount] Script Date: 02/18/2016 14:23:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER function [dbo].[getCount]
(
@id int
)
returns @t table ( ccount int, kcount int)
as
begin
declare @ccount int,@kcount int;
with nodes
as
(
select * from k_type where parentid=@id
union all
select child.* from k_type as child,nodes par where child.parentid=par.id
)
select @ccount=COUNT(1) from nodes;
with nodes2
as
(
select * from k_type where id=@id
union all
select child.* from k_type as child,nodes2 par where child.parentid=par.id
)
select @kcount=count(1) from k_info where status=1 and typeid in ( select id from nodes2)
insert into @t(ccount,kcount) select @ccount,@kcount -- values(@ccount,@kcount);
return ;
GO
/****** Object: UserDefinedFunction [dbo].[getCount] Script Date: 02/18/2016 14:23:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER function [dbo].[getCount]
(
@id int
)
returns @t table ( ccount int, kcount int)
as
begin
declare @ccount int,@kcount int;
with nodes
as
(
select * from k_type where parentid=@id
union all
select child.* from k_type as child,nodes par where child.parentid=par.id
)
select @ccount=COUNT(1) from nodes;
with nodes2
as
(
select * from k_type where id=@id
union all
select child.* from k_type as child,nodes2 par where child.parentid=par.id
)
select @kcount=count(1) from k_info where status=1 and typeid in ( select id from nodes2)
insert into @t(ccount,kcount) select @ccount,@kcount -- values(@ccount,@kcount);
return ;
end
调用方法:
select * from dbo.getCount(0) b
0 0
- 一个函数返回多个值
- Javascript函数返回多个值
- C#函数返回多个值
- 函数如何返回多个值
- python 函数返回多个值
- java函数返回多个值
- 函数通常返回多个值
- python函数返回多个值
- 让函数返回多个值
- python函数返回多个值
- php 函数返回多个值
- 函数返回多个值
- 函数返回多个值
- python 函数返回多个值
- lua函数返回多个值
- java:函数--返回多个值
- 函数返回多个值的方法;
- asp 函数调用返回多个值
- ACM-JAVA-1001-A+B
- TextView(文本框)详解
- php,is_null 和==null为何结果不同?
- Codeforces 25A IQ test
- 买卖时机APP 开启股票交易大数据时代!
- 函数返回多个值
- Weblogic构建jms服务
- Windows版本编译运行React Native官方实例UIExplorer项目
- 冬眠结束,醒醒吧
- POJ3278 爆搜,不要像我一样作死就好
- LeetCode Bulls and Cows
- Unsupported major.minor version (jdk版本错误)
- 操作系统ahci aci ide模式
- 兼容浏览器