create function f(...)
请教调用f的语法?

解决方案 »

  1.   

    如果表值函数
    select * from dbo.f(...) as t如果标量函数
    select dbo.f(...) as t
      

  2.   

    create function test(@Num varchar(20))--@Num 参数
    returns varchar(50) --返回值类型
    as
    begin
    declare @MSG varchar(20)
    if(@Num =1)
        select @MSG ='正确'
    else
        select @MSG ='错误'
    return @MSG
    end
    --调用函数
    select dbo.test(2)--传递参数2
      

  3.   

    create function GetTableDetails()
    returns TABLE
    as 
        return (select * from sales )--调用函数
    select * from dbo.GetTableDetails()--dbo.需要注意
    --返回sales表的所有记录。