sqlserver 存储过程和自定义函数

WBOY
发布: 2016-06-07 15:07:13
原创
1450 人浏览过

sqlserver 存储 过程 create procedure proc_menu ?@menuId varchar(50), ?@menuTotal int output as begin ?? set nocount on; ?? select @menuTotal=count(*) from dbo.Lov_menu t where t.menu_id=@menuId; end sqlserver 自 定义 函数 create function S

sqlserver 存储过程

create procedure proc_menu
?@menuId varchar(50),
?@menuTotal int output
as
begin
?? set nocount on;
?? select @menuTotal=count(*) from dbo.Lov_menu t where t.menu_id=@menuId;
end

sqlserver 自定义函数

create function Sector_Name(@sctId varchar(10))
returns varchar(50)
as
begin
declare @ccode varchar(50)
declare @name? varchar(50)
declare @pid?? varchar(10)
declare @sctpid varchar(10)
declare @spid?? varchar(10)

select @pid=SCT_PID? from SECTOR where SCT_ID=@sctId
if(@pid=1)
?? set @ccode=(select SCT_NAM from SECTOR where SCT_ID=@sctId)
else if(@pid=0)
?? set @ccode=(select SCT_NAM from SECTOR where SCT_ID=@sctId)
else
begin
?? select @name? =SCT_NAM? from SECTOR where SCT_ID=@sctId
?? select @sctpid=SCT_PID? from SECTOR where SCT_ID=@pid
?? if (@sctpid=1)
? set @ccode =(select SCT_NAM? from SECTOR where SCT_ID = @pid )+'-'+@name
?? else
??? begin
??? while @sctpid 1
?? begin
??? select @spid=SCT_PID? from SECTOR where SCT_ID = @sctpid
??? set @ccode =(select SCT_NAM? from SECTOR where SCT_ID = @sctpid )+'-'+@name
??? set @sctpid=@spid
??? if @sctpid=1
????break
?? end?
?end
end
return @ccode
end

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板