0

我使用下面的代码来创建函数但是当我想执行它时发生错误

CREATE FUNCTION getFactorPriceFunction
(
    @factorCode BIGINT
)
RETURNS bigint
AS BEGIN
    RETURN 
    (
        select SUM(price*coun) as total from CustomerFactor inner join CustomerFactorDetails 
        on CustomerFactor.code=CustomerFactorDetails.factorCode inner join ProductDetails on
        ProductDetails.code=CustomerFactorDetails.productDetailsCode
        where factorCode=@factorCode AND final=1
    )
END 

执行:

 select total from getFactorPriceFunction(100)

错误:

无效的对象名称“getFactorPriceFunction”

4

2 回答 2

0
  1. 它被称为dbo.getFactorPriceFunction
  2. 调用是这样的:

    select dbo.getFactorPriceFunction(100) as total
    
于 2013-05-23T04:33:38.420 回答
-1

既然它是一个scalar value函数,它应该像这样执行

select dbo.getFactorPriceFunction(100)

如果您要返回一张桌子,那么它应该是

select total from dbo.getFactorPriceFunction(100)
于 2013-05-23T04:34:04.837 回答