I have 2 tables(Table A & Table B).I wish to read one by one records from Table A and compare with Table B.Currently we have use cursor for this purpose.But the SQL Server is waiting on the I/O to complete after a Log block in cache is flushed from Memory to Disk. Any body know about alternative solution to avoid
cursor.It will very helpful to me.
Table A values CustID transID Group Count 1 5 T1 20 1 6 T1 10 1 7 T1 30 Table B values CustID transID Group Count 1 8 T2 5 1 9 T2 20 1 10 T2 10 Currently I have introduce 2 cursors,1 for table A and another for Table B read the records from both tables and compare the count and balance should be retain to next level. EG :read transID 5 & 8,and compare the count (20,5) get the min count(5). The rest of the count 15 compare with transID 5 & 9 and compare the count (15,20) for this line balance count is available in transID 9(balance count is 5) Then compare with transID 6 & 9 this process is continues this way. cursors details. declare group1_cursor cursor local read_only type_warning for select * from Table A declare group2_cursor cursor local read_only type_warning for select * from Table B