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')

Subscribe to Our Blog

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

You have been successfully Subscribed! Ops! Something went wrong, please try again.

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.

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.

Get a Free Quote Today

"*" indicates required fields

Let us know how many licensed Microsoft 365 users you have.

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: