+ Start a Discussion
Pavushetti AbhilashPavushetti Abhilash 

Retrieved records by soql should save in a new list.

Soql query to get 100 records from account.
List<account> acctList = [select id, name from account limit 100]. The retrieved 100 records should save in NEW LIST. How could i accomplish.
Danish HodaDanish Hoda
List<account> newAcctList = new List<account>();
newAcctList.addAll(acctList);
CharuDuttCharuDutt
Hii Pavushetti Abhilash
Try Below Code
list<Account> list1 = new list<Account>();
list<Account> list2 = [select id,Name from Account];

list1.addAll(list2);
System.debug(list1);
Please Mark It As Best Answer If It Helps
Thank You!