Write Procedures or ETL Query
Hi People, I have a table which has CustNo, InvoiceNo, Invoice Amnt, TotalAmount Cust Invoice InvAmnt BalanceAmnt 106032 17007 11073.60 11073.60 106032 17007 -9953.28 1120.32 106032 17007 -451.06 669.26 106032 17007 -669.26 0 I need to update this "BalanceAmnt" field like above. There are many customers and each customer could have many Invoices. To identify each line there are line sequence No's available. I tried with some while condition but it doesn't work. Can any one help me on this? Thank You
November 30th, 2011 1:09am

Ís BalanceAmnt equel to TotalAmount? Are you trying to calculate the last column?Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
November 30th, 2011 1:54am

Yes ...but here iam trying to calculate sum of invoice amount at each row level
November 30th, 2011 2:25am

If you want to compair rows (f.e. InvAmnt of previous row and InvAmnt current row) then a Script Component is probably the best option. Here is an example of that. // Variables to store the previous row int Cust = ""; int Invoice = 0; decimal InvAmnt = 0; public override void Input0_ProcessInputRow(Input0Buffer Row) { // Compare current key with previous key if ((Row.Cust == Cust) && (Row.Invoice == Invoice)) { // Keys match, so you can compare current invoicerow with previous invoice Row.BalanceAmnt = InvAmnt - Row.InvAmnt; } else { // Keys don't match, so this is the first row Row.BalanceAmnt = Row.InvAmnt; } // Store current row values in the variables for the next row Cust = Row.Cust ; Invoice = Row.Invoice; InvAmnt = Row.InvAmnt; } Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
November 30th, 2011 3:56am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics