I have a larger query that consists of a lot of parenthetical SELECT statements. Some of these parenthetical SELECT statements are results of table-based function results. To make things briefer, here is a snippet that doesn't return anything for the function result. I need to feed the Supplier Code into the function for each row of the result. Since this is a table-based function, I purposely am pulling just the top row of its result.
Any suggestions on how I can handle this? I cannot directly to refer to the Su.Code value as the function argument, so I tried using local variables. Still I wind up with NULL as the result.
declare @Supplier varchar(255) declare @OwnedCost money select top 10 @Supplier = Su.Code, @OwnedCost = (select TOP 1 OwnedCost from dbo.fncVendorHistorical(@Supplier, '6/1/2013', '6/1/2013')) from tbl330_Suppliers Su order by Su.Code