String sfields= ''; Map<String, Schema.SObjectField> objectFieldMap = Schema.getGlobalDescribe().get('CustomSettingAPI').getDescribe().fields.getMap(); for(Schema.SObjectField column: objectFieldMap.values()) { sQuery += column+', '; } system.debug(sfields); // here u can see all fields.
String sfields= '';
Map<String, Schema.SObjectField> objectFieldMap = Schema.getGlobalDescribe().get('CustomSettingAPI').getDescribe().fields.getMap();
for(Schema.SObjectField column: objectFieldMap.values()) {
sQuery += column+', ';
}
system.debug(sfields); // here u can see all fields.
You can use global describe for this purpose
This will return you map of FieldAPI and SObject Field. This works for any custom object and as well as on Custom Settings.
For Further detail have a look here http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_describe_objects_understanding.htm