Query CDS Data using SQL from Power BI or SSMS (Preview)

You are currently viewing Query CDS Data using SQL from Power BI or SSMS (Preview)

Recently Microsoft has announced a preview of an additional way to access read-only data in CDS. The TDS endpoint for CDS allows read-only access to the system for reporting and analytics. The Tabular Data Stream (TDS) Protocol endpoint is managed by an administrator.

So far,  the CDS OData endpoint served as the single access point for all types of operations. In this preview feature, the TDS endpoint is limited to read-only actions. As TDS implies, Power Platform is providing access to CDS data in a tabular format. With the addition of TDS, we have the benefit of allowing additional applications access to CDS data.
However, current support is limited to SSMS (v18.4 and higher) and Power BI applications.

Prerequisites:

Before we can start using this preview feature, we need to ensure that TDS endpoint is enabled as without it we can’t use this feature via Power BI or SSMS.

  1. Sign in to Power Apps, and then select the appropriate sandbox environment. (Don’t try preview features in Production Environment).
  2. Verify that your environment has at least version 9.1.0.17437.
  3. Enable the TDS endpoint feature in Power Platform admin center.
Connect to CDS SQL - Enable TDS Endpoint

If you don’t have the Analyze in Power BI option in your Power Apps environment, you don’t have access to the SQL connection feature yet.

View CDS Entity Data in Power BI

Connect to CDS SQL - Analyze in Power BI
  1. Sign in to Power Apps, and then select the appropriate environment from the top-right corner.
  2. On the left navigation pane expand Data, select Entities, and then select Analyze in Power BI on the command bar.
    It will download the pbids file for your environment.
  3. Open the .pbids file to access it in Power BI Desktop.
  4. In the SQL Server database dialog box, select Microsoft account, select Sign in, and then in the browser window that appears enter your credentials.

SQL options, such as a T-SQL queries aren’t supported.

View entity data in Power BI Desktop

Query CDS Data using SSMS

  • You can also use SQL Server Management Studio (SSMS) version 18.4 or later with the CDS endpoint SQL connection.
  • The CDS endpoint SQL connection uses the CDS security model for data access. Data can be obtained for all entities to which a user has access to in Common Data Service.
  • Only Azure Active Directory authentication is supported. SQL authentication and Windows authentication are not supported.
Connect to CDS SQL - SSMS

If you are familiar with the Dynamics 365 On-Premises, you might know the difference between the query on Filtered Views (like Filteredaccount) and direct tables (like account).
Now, the tables exposed via TDS protocol seems to be similar to Filtered view as it provides all the features like Optionset Names, Datatime fields in Local time and so on. Check out the sample queries in below screenshot.

Connect to CDS SQL - SSMS Query

Row-level security works with TDS endpoint protocol too.

For example, if a user has a Security Role in CDS that enabled them to only read/view their own contacts, that rule would be still in place even though they are accessing through Power BI and SSMS.

Field Level security works as expected as well.

Field Level security assignments with Read-Access set as “No” will have NULL values when queried through Power BI and SSMS.

The list of supported SQL operations includes:

  • Batch operations
  • SELECT
  • Aggregation functions (i.e., Count() and Max() functions)
  • UNIONs and JOINs
  • Filtering

Well, I hope everyone would like to try out this feature and analyse it against the OData connection.
As it is in the Preview mode, we can expect some changes in future before release.
Till next time, Cheers 😉

Manish Rawat

Microsoft Certified: Dynamics 365 + Power Platform Solution Architect Expert, with little Knowledge of Scrum (PSM-I) & keen to learn about Power Platform 😎