Sample Code:
Id recordId = '00128000002KuXO'; DescribeSObjectResult descResult = recordId.getSObjectType().getDescribe(); List<String> fieldList = new List<String>(descResult.Fields.getMap().keySet()); String query = ' SELECT ' + String.join(fieldList, ',') + ' FROM ' + descResult.getName() + ' WHERE ' + ' id = :recordId'; List<sObject> records = Database.query(query); System.debug(records);