我写了一个存储过程...但是提示出错误.说是TugboatList是一个不可识别的函数
--------------------------------------------------------------------------
CREATE FUNCTION TugboatList (@InEmpId nvarchar(10))
RETURNS nvarchar(500) 
as
begin
declare @s nvarchar(2000)
set @s=''
select @s=@s+','+TugboatName+'' from ShangJSD_Son where AccountID=@InEmpId
return stuff(@s,1,1,'')
end
GO
select *,TugboatList(AccountID) as tnb from ShangJSD_Mather  order by Unid desc
GO

解决方案 »

  1.   

    你看下sqlcreate function的模板,就知道你那里出错了。。
      

  2.   

    CREATE FUNCTION TugboatList (@InEmpId nvarchar(10))
    RETURNS nvarchar(500) 
    as
    begin
    declare @s nvarchar(2000)
    set @s=''
    select @s=@s+','+TugboatName+'' from ShangJSD_Son where AccountID=@InEmpId
    return stuff(@s,1,1,'')
    end--你创建的是函数,而不是存储过程,改为如上试试
      

  3.   

    如果要查询用如下
    select *,dbo.TugboatList(AccountID) as tnb from ShangJSD_Mather  order by Unid desc要在函数TugboatList前加dbo.
      

  4.   

    select *,TugboatList(AccountID) as tnb from ShangJSD_Mather  order by Unid desc
      这句肯定有问题啊。
      

  5.   

    TO(小山):我是创建的函数函数写是这样的做的.然后用一条SQL语句来做查询.就像你上面写的一样分两个部份.
    --------------------------------------------------------------------
    我怎么样才可以把上面那一部份做为存储过程来存呢.要是放在程序当中太多了.也不知道怎么样加到程序当中来用.
      

  6.   

    哈哈...我找到原因了....只怪自己不注意看文字....SQL管理器当中有一个自定义函数功能.看到了.打开就有了.