Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Splitfn", or the name is ambiguous Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Splitfn", or the name is ambiguous sql-server sql-server

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


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.


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 


A general answer

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

but

select [dbo].[SplitString]('1,2',',')  -- will **not** work and throws this error