I've got a table of items that 77,000 item_id 's. The ERP system has a convoluted way to calculate the unit price based on customer id, price library, price book and price page.
They've written a stored procedure that calculates the unit price. I used a SQL trace to grab the stored procedure call the web app is used. I've look at the stored procedure, and it's about 300 pages long. Far too long for me to reverse engineer what they've done. I need to find a way to get the unit price for each item_id.
This would give the item_id's
select item_id from inventory
I'd like to run something like this
select item_id, (select unit_price from exec pricelib @item_id=item_id) as unit_price from inventory
But of course that does not work on sql server 2019.
The stored procedure only gets a single price, based off a single item_id.
Anyone have any ideas?