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