Occasionally, I need (or want – depending on your preference) a list of all the attributes (basic CRM metadata) in a Dynamics CRM organization. While there are several ways, including some great document generators, that will get such a list for you, SQL is always an option. If you are on-premises, or working in a developer VM, you can run this query against a CRM organization database to get the basic details. It can also be used as a starter for more complicated metadata query requirements.
SELECT en.LogicalName , en.ObjectTypeCode , att.LogicalName , typ.Description , typ.XmlType FROM MetadataSchema.Entity en JOIN MetadataSchema.Attribute att on en.EntityId = att.EntityId JOIN MetadataSchema.AttributeTypes typ on att.AttributeTypeId = typ.AttributeTypeId ORDER BY en.LogicalName , att.LogicalName