Cannot find either column “dbo” or the user-defined function or aggregate “dbo.Splitfn”, or the name is ambiguous

前端 未结 4 1814
无人及你
无人及你 2020-12-01 13:53

Hai guys,

I ve used the following split function,

CREATE FUNCTION dbo.Splitfn(@String varchar(8000), @Delimiter char(1))       
returns @temptable TA         


        
相关标签:
4条回答
  • 2020-12-01 14:04

    It's a table-valued function, but you're using it as a scalar function.

    Try:

    where Emp_Id IN (SELECT i.items FROM dbo.Splitfn(@Id,',') AS i)
    

    But... also consider changing your function into an inline TVF, as it'll perform better.

    0 讨论(0)
  • 2020-12-01 14:05

    You need to treat a table valued udf like a table, eg JOIN it

    select Emp_Id 
    from Employee E JOIN dbo.Splitfn(@Id,',') CSV ON E.Emp_Id = CSV.items 
    
    0 讨论(0)
  • 2020-12-01 14:12

    A general answer

    select * from [dbo].[SplitString]('1,2',',') -- Will work 
    

    but

    select [dbo].[SplitString]('1,2',',')  -- will not work and throws this error
    
    0 讨论(0)
  • 2020-12-01 14:13

    Since people will be coming from Google, make sure you're in the right database.

    Running SQL in the 'master' database will often return this error.

    0 讨论(0)
提交回复
热议问题