Reputation: 243
I have a stored procedure that uses a CTE to find total cost and cost per piece of an assembly (bill of materials).
My question is, is it possible to call the stored procedure as part of a select statement to calculate yield? I imagine it would look a little like this
SELECT
(CASE WHEN ItemType = 'BOM' THEN (SalePrice * QTYSOLD)
- ((EXEC dbo.sp_GETBOMUNITCOST ASMNumber) * QTYSOLD) /* Dynamically select parameter for each line */
FROM
dbo.SalesLine
Upvotes: 1
Views: 153
Reputation: 6405
You would need to create a scalar function instead of a stored procedure to use it inline in a query.
Upvotes: 1