How do I query Salesforce Knowledge Base Articles from SQL Server?
A customer was unable to query Salesforce Knowledge Base articles from SQL Server. The queries were failing with the error "MALFORMED_QUERY." The workaround was to use SQL Server's OPENQUERY
function to execute a pass-through query, which then succeeded. For example, this query:
SELECT * FROM MYLINKEDSERVER.SF.DBO.KnowledgeArticleVersion WHERE PublishStatus = ''Draft'' AND [language] = ''en_US''
was replaced with:
SELECT * FROM OPENQUERY(MYLINKEDSERVER, 'SELECT * FROM KnowledgeArticleVersion WHERE PublishStatus = ''Draft'' AND [language] = ''en_US'' ')
This illustrates an issue that other customers have faced when using a linked server to work with Salesforce data. Queries such as SELECT * FROM SALESFORCE.SF.DBO.Account
may be modified by SQL Server in such a way that make them invalid for the target data source. This is not the case for queries executed with OPENQUERY
.
For a step-by-step tutorial that shows how to connect SQL Server to Salesforce, refer to this this Easysoft article.