我正在尝试创建一个存储过程,它将INNER JOIN
根据参数值执行代码块。但是,我不断收到“'@reSourceID' 附近的语法错误”。
if (@VendorID = 11)
@reSourceID = 't.reSourceID'
if (@VendorID = 5)
@reSourceID = 't.SourceID'
SELECT t.ID, fsg.SigCap, fsg.VendorId
FROM FormCap fsg
INNER JOIN FlightTrip t
ON fsg.SourceId = @reSourceID
AND fsg.VendorId = @VendorID
INNER JOIN ContractProvider cpu
ON t.Id = cpu.VendorId
WHERE (t.ID = @FinTransID)
AND (cpu.userID = @UserID)
有什么想法会导致错误吗?