Jess31
asked on
UDF - What is causing this error?
I am getting this error when trying to compile.
Error:
Msg 102, Level 15, State 1, Procedure xTest, Line 43 [Batch Start Line 7]
Incorrect syntax near '@BookList'.
Function:
Error:
Msg 102, Level 15, State 1, Procedure xTest, Line 43 [Batch Start Line 7]
Incorrect syntax near '@BookList'.
Function:
create FUNCTION [dbo].[xTest]
(
@ShippingCost smallmoney = 0
)
RETURNS @BookList Table (
ISBN nvarhcar(13),
Title nvarchar(150),
Publisher nvarchar(150)
)
AS
Begin
With CTE As(
Select g.ISBN,
g.Title,
Case when bp.ISBN Is Null
Then g.Publisher Else bp.Publisher End
As Publisher,
@ShippingCost As ShippingCost
From tblGuides g
Join tblGuideHeader gh On g.GuideNumber = gh.GuideNumber
Join tblPOSupplierItemList sl On g.ISBN = sl.ISBN
Left Join tblBookPublisher bp On bp.ISBN = g.ISBN
where gh.FinalShipDate < getDate()
And
(dbo.QtyLeft_Guide(g.GuideNumber, g.ISBN) > 0)
)
select ISBN, Title, Publisher, ShippingCost
Into xxxx from cte
Select ISBN, Title, Publisher
Into @BookList
from xxxx Where ShippingCost = 1
return
End
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.