I need to update all the accounts based on Global Account. I am doing it in a stored procedure(SQL server 2005). Using Old way, is to create outer cursor for all the fields in Global account. Then create second cursor within this outer cursor for each account. if that record does not exist, add it and move to the next record from the global account.
I have heard that one should not use Cursors any more for performance issues. How would I accomplish it the modern, more efficient way?
My pseudo code would look like:
Select * from GlobalAccounts
Select * All_Accounts
While not EOF.All Accounts
While not GlobalAccount.EOF
if GlobalAccount.record is not already present in AllAccount.current record then,
AllAccount.CurrentRecord Add GlobalAccount.Current Record
The only way i know is to use cursor. Please help me if there is a better way to do it so performance is not slow. Thank you