I am still kind of a beginner here but I created this UDF:
我仍然是一个初学者,但我创建了这个UDF:
USE NorthWind
GO
IF EXISTS(SELECT name FROM SYSOBJECTS
WHERE name='SaleAfterDiscount'
AND type ='FN')
BEGIN
DROP FUNCTION SaleAfterDiscount;
END
GO
CREATE FUNCTION SaleAfterDiscount(@pPrice AS MONEY, @pQty AS SMALLINT, @pDiscount AS REAL)
RETURNS MONEY AS
BEGIN
DECLARE @SaleAfterDiscount MONEY;
SET @SaleAfterDiscount=(@pPrice*@pQty*(1-@pDiscount));
RETURN @SaleAfterDiscount;
END;
Then I go to use this UDF to get a value and I get this error that says "The Multi-Part Identifier "dbo.SaleAfterDiscount" could not be bound. I am not sure what I did wrong. Can anyone help?
然后我去使用这个UDF得到一个值,我得到这个错误,说“多部分标识符”dbo.SaleAfterDiscount“无法绑定。我不知道我做错了什么。有人可以帮忙吗?
1 个解决方案
#1
1
Since the CREATE FUNCTION does not specify a schema, it is likely it being created in a different schema (depends on your user config).
由于CREATE FUNCTION没有指定架构,因此很可能是在不同的架构中创建(取决于您的用户配置)。
Try changing the CREATE to look like below
尝试将CREATE更改为如下所示
CREATE FUNCTION dbo. SaleAfterDiscount
创造功能dbo。 SaleAfterDiscount
#1
1
Since the CREATE FUNCTION does not specify a schema, it is likely it being created in a different schema (depends on your user config).
由于CREATE FUNCTION没有指定架构,因此很可能是在不同的架构中创建(取决于您的用户配置)。
Try changing the CREATE to look like below
尝试将CREATE更改为如下所示
CREATE FUNCTION dbo. SaleAfterDiscount
创造功能dbo。 SaleAfterDiscount