How it is calculated?
>The problem I'm trying to solve is that the quantity on hand need to be calculated at run time for each inventory record. I'm open to any suggestions on how to do this.
>
>Thanks
>
>
>
>
>>>What's the correct syntax for calling this SP for each row to be returned?
>>>
>>>
>>>
>>>DECLARE @iInventoryOnHand INT
>>>DECLARE @sProdCode VARCHAR(15)
>>>
>>>
>>>
>>>EXEC spGetInventoryOnHand @sProdCode, @iInventoryOnHand OUTPUT
>>>
>>>SELECT i.sProduct_CD, <<call SP here>>
>>> FROM Inventory i
>>> JOIN Product p ON p.sProduct_CD = i.sProduct_CD
>>> WHERE i.decInv_Physical_Qty <> 0 OR
>>> (@iInventoryOnHand > 0 and p.sCommodity_CD <> 'M')
>>>
>>>
>>
>>William is right,
>>You can't call SP inside of SELECT but you can call function.
>>But that will slow down the performance. What code you have in that SP?
>>Can you use directly that code as derived table?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.