function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sreekanth cheerasreekanth cheera 

Transfer the data

I have one Account record named Banking
And it has child contact records.

And I created one more Account named Finance 
And the requirement is Banking should be deleted and whatever the banking chid records to transfer to the finance account
Best Answer chosen by sreekanth cheera
Bhargavi TunuguntlaBhargavi Tunuguntla
Hi sreekanth,

I think the below will work for your requirement :
List<Contact> conList=[select id,AccountId from contact where Account.name=:'Banking'];
Account acc=[select id from Account where name=:'finance'];
Account acc1=[select id from Account where name=:'banking'];
for(Contact con:conList)
{
    con.accountId=acc.id;
}
update conList;
delete acc1;

Run the code in anonymous block.