[SalesForce] how to get all the fields of a custom setting in soql

I want to access all the fields of a custom setting via soql? any ideas how to do it.

Best Answer

As mentioned in comments take a look at Custom Settings Methods. You might actually not need to perform a SOQL query. E.g.

// Example for get a single List custom setting
MyListCustomSetting__c listCS = MyListCustomSetting__c.getInstance(customSettingsName);

// Example for get a list of all List custom setting records
List<MyListCustomSetting__c> listCSlist = MyListCustomSetting__c.getAll();

// Example for get a org-wide Hierarchy custom setting
MyListCustomSetting__c listCS = MyListCustomSetting__c.getOrgDefaults();

// Example for get a Hierarchy custom setting for specific user or pro
MyListCustomSetting__c listCS = MyListCustomSetting__c.getInstance(userOrProfileId);

If you still need SOQL, take a look at dynamic SOQL in combination with field describe.