I'm using Microsoft Dynamics CRM 2016 On Premise, I'm trying to get some specific metadata, basically get through SQL Server the field physical name, display name(Label) and the field value from a given entity. This is the query I have so far:
select a.PhysicalName, I.Label
from [dbo].[Attribute] a
inner join [dbo].[Entity] e on e.EntityId=a.EntityId
inner join [dbo].[LocalizedLabel] l on l.ObjectId = a.AttributeId
where e.Name='DesiredEntityName'
With this query I can get the fields and displayed label from the given entity, however I don't see the way on how to join and get the list of values for each field.