created a function in SQL Server but can't call it from SP?
I created a function in my SQL Server 2008 using the code here: http://www.log开发者_运维技巧iclabz.com/sql-server/split-function-in-sql-server-to-break-comma-separated-strings-into-table.aspx
I see it in my DB under Programability > Functions > Table-valued Functions > dbo.Split
but when I try and call in in my SP code:
SELECT ItemID
FROM StagingCategoryItems
WHERE ManufacturerID = @ManufacturerID
AND CategoryID = @CategoryID
AND ItemID IN (
dbo.Split(@InIds,',')
)
I get this error:
Msg 4121, Level 16, State 1, Line 11
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Split", or the name is ambiguous.
What am I missing here?
You need to use the function as a tablename in the select clause as it is a table valued function.
Try this:
SELECT ItemID
FROM StagingCategoryItems
WHERE ManufacturerID = @ManufacturerID
AND CategoryID = @CategoryID
AND ItemID IN (SELECT items
FROM dbo.Split(@InIds,',')
)
精彩评论