Search
Close this search box.

T-SQL for Picklist Values in CRM 2011

How to Write T-SQL for Picklist Values in Microsoft Dynamics CRM

Getting at the Picklist Values (a.k.a., Option Sets) is not easy.  It’s not hard either.  As you know, the picklist values are stored in the entity as numerical values, not the character-based descriptive values.  But how to get at the descriptive values that are useful to we humans?

 

Here’s a sample query giving you T-SQL for Picklist Values.  This example is for Leads (ObjectTypeCode 4), and a custom picklist value for County (sync_county).  The key table you want to get access to is the StringMap table.  But you have to put a couple of strategic filters in place to make it work.

 

SELECT LeadBase.CompanyName, LeadBase.FirstName, LeadBase.LastName, LeadExtensionBase.Sync_County, StringMap.AttributeName, StringMap.Value
FROM LeadBase INNER JOIN
LeadExtensionBase ON LeadBase.LeadId = LeadExtensionBase.LeadId INNER JOIN
StringMap ON LeadExtensionBase.Sync_County = StringMap.AttributeValue
WHERE (StringMap.ObjectTypeCode = 4) AND (StringMap.AttributeName = N'sync_county')

Stay informed with our latest content

opt-in for occasional emails with latest blog articles, promotions, and webinar invites.

Subscribe Our Blog

Hidden

Next Steps: Sync an Email Add-On

To get the most out of your form, we suggest that you sync this form with an email add-on. To learn more about your email add-on options, visit the following page (https://www.gravityforms.com/the-8-best-email-plugins-for-wordpress-in-2020/). Important: Delete this tip before you publish the form.

Download DataStream Checklist of Cybersecurity Requirements for Cyber Insurance gated conent

"*" indicates required fields

Embark on your digital transformation journey with our **Free Small Business IT Assessment** and unlock the potential of cloud technology for enhanced cybersecurity, productivity, and growth.
Stay informed with our latest content:

Contct Us

Schedule a Demo

"*" indicates required fields

Embark on your digital transformation journey with our **Free Small Business IT Assessment** and unlock the potential of cloud technology for enhanced cybersecurity, productivity, and growth.
Opt-in

Schedule a CRM Assessment

"*" indicates required fields

Embark on your digital transformation journey with our **Free Small Business IT Assessment** and unlock the potential of cloud technology for enhanced cybersecurity, productivity, and growth.
Stay informed with our latest content:

Get a Free Quote Today

"*" indicates required fields

Let us know how many licensed Microsoft 365 users you have.
Stay informed with our latest updates:

Microsoft 365 Licensing Consultation

"*" indicates required fields

We would love to answer any questions you may have on Microsoft 365 licensing. Let us know how we can help.
Stay informed with our latest content:
This field is for validation purposes and should be left unchanged.

Download our Microsoft 365 Business Premium * Day 1 * Security Setup Checklist

"*" indicates required fields

Stay informed with our latest content:

Free Small Business IT Assessment

"*" indicates required fields

Embark on your digital transformation journey with our **Free Small Business IT Assessment** and unlock the potential of cloud technology for enhanced cybersecurity, productivity, and growth.
Stay informed with our latest content: