I have a process that I'm converting to T-SQL from VBA (which of course uses looping), and I wanted to see if it could be used without touching each row.
Here's the situation. A payment is received. There are one or more line items against which the payment can be posted. (You may have seen similar behavior in QuickBooks or MS Pro Accounting)
What needs to happen is that the $500 is distributed against these items.
I can easily figure out how to do this row-by-row... but wanted to see if there's a set-based solution.
Thanks in advance for your guidance!
Bryant Farley
EG&G Technical Services
Here's the situation. A payment is received. There are one or more line items against which the payment can be posted. (You may have seen similar behavior in QuickBooks or MS Pro Accounting)
Code:
Example: $500 received
Item 1 = $250
Item 2 = $200
Item 3 = $50
Item 4 = $100
What needs to happen is that the $500 is distributed against these items.
Code:
Item 1 = $250 of $500 distributed; $250 remaining
Item 2 = $200 of remaining $250 distributed; $50 remaining
Item 3 = $50 of remaining $50 distributed; $0 remaining
Item 4 = nothing happens since $0 remaining
I can easily figure out how to do this row-by-row... but wanted to see if there's a set-based solution.
Thanks in advance for your guidance!
Bryant Farley
EG&G Technical Services