I am still kind of a beginner here but I created this 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?