找不到任一列“dbo"或用户定义的函数或聚合“dbo.Splitfn",或名称不明确 [英] Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Splitfn", or the name is ambiguous
本文介绍了找不到任一列“dbo"或用户定义的函数或聚合“dbo.Splitfn",或名称不明确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我使用了下面的分割函数,
I ve used the following split function,
CREATE FUNCTION dbo.Splitfn(@String varchar(8000), @Delimiter char(1))
returns @temptable TABLE (items varchar(8000))
as
begin
declare @idx int
declare @slice varchar(8000)
select @idx = 1
if len(@String)<1 or @String is null return
while @idx!= 0
begin
set @idx = charindex(@Delimiter,@String)
if @idx!=0
set @slice = left(@String,@idx - 1)
else
set @slice = @String
if(len(@slice)>0)
insert into @temptable(Items) values(@slice)
set @String = right(@String,len(@String) - @idx)
if len(@String) = 0 break
end
return
end
我在查询中使用了这个函数并且它被执行了
and i used this function in a query and it was executed
ALTER PROCEDURE [dbo].[Employees_Delete]
-- Add the parameters for the stored procedure here
@Id varchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
if exists( select Emp_Id from Employee where Emp_Id=dbo.Splitfn(@Id,','))
begin
update Employee set Is_Deleted=1 where Emp_Id=dbo.Splitfn(@Id,',')
select 'deleted' as message
end
END
但是当我执行我的存储过程给出值时说 (1,2) 我得到了错误
but when i excute my store procedure giving values say (1,2) i got the error
Cannot find either column "dbo" or the user-defined
function or aggregate "dbo.Splitfn", or the name is ambiguous.
我已经检查了我的表值函数,函数splitfn"在那里,但我不知道出了什么问题?任何建议..
I ve checked my tablevalued functions the function 'splitfn' was there but i dont know what is going wrong? Any suggestions..
推荐答案
这是一个表值函数,但您将其用作标量函数.
It's a table-valued function, but you're using it as a scalar function.
试试:
where Emp_Id IN (SELECT i.items FROM dbo.Splitfn(@Id,',') AS i)
但是...也可以考虑将您的函数更改为内联 TVF,因为它会表现得更好.
But... also consider changing your function into an inline TVF, as it'll perform better.
这篇关于找不到任一列“dbo"或用户定义的函数或聚合“dbo.Splitfn",或名称不明确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文