SQL Server 的三种用户自定义函数

create function fun_A()   #标题函数、create function fun_name() returns output_type as begin return value end;
returns int
as
begin
return 1;
end
go

create function fun_B() #多语句用户定义函数、create function fun_name() returns @value table(colum_list) as begin return ; end 
returns @tb table(ID int ,Name nvarchar(8))
as
begin
insert into @tb(ID,Name) values(1,'111'),(2,'222');
return;
end
go


create function fun_C() #内联用户定义函数、create function fun_name() returns table as return select......;
returns table
as
return select 1 as A,2 as B,3 as C;
go

posted on 2014-10-26 20:27  蒋乐兴的技术随笔  阅读(494)  评论(0编辑  收藏  举报

导航