首頁 >資料庫 >mysql教程 >sqlserver 存储过程和自定义函数

sqlserver 存储过程和自定义函数

WBOY
WBOY原創
2016-06-07 15:07:131487瀏覽

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

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn