我使用下面的代码来创建函数,但是当我想执行它时会发生错误
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'
答案 0 :(得分:0)
dbo.getFactorPriceFunction
。 调用如下:
select dbo.getFactorPriceFunction(100) as total
答案 1 :(得分:-1)
由于它是scalar value
函数,因此应该像
select dbo.getFactorPriceFunction(100)
如果你要退回一张桌子,那么它应该是
select total from dbo.getFactorPriceFunction(100)