Ready to get started?

Learn more about the CData ODBC Driver for SQL Analysis Services or download a free trial:

Download Now

Connect to SQL Analysis Services as an External Data Source using PolyBase

Use the CData ODBC Driver for SQL Analysis Services and PolyBase to create an external data source in SQL Server 2019 with access to live SQL Analysis Services data.

PolyBase for SQL Server allows you to query external data by using the same Transact-SQL syntax used to query a database table. When paired with the CData ODBC Driver for SQL Analysis Services, you get access to your SQL Analysis Services data directly alongside your SQL Server data. This article walks through creating an external data source and external tables to grant access to live SQL Analysis Services data using T-SQL queries.

The CData ODBC drivers offer unmatched performance for interacting with live SQL Analysis Services data using PolyBase due to optimized data processing built into the driver. When you issue complex SQL queries from SQL Server to SQL Analysis Services, the driver pushes down supported SQL operations, like filters and aggregations, directly to SQL Analysis Services and utilizes the embedded SQL engine to process unsupported operations (often SQL functions and JOIN operations) client-side. And with PolyBase, you can also join SQL Server data with SQL Analysis Services data, using a single query to pull data from distributed sources.

Connect to SQL Analysis Services

If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs. To create an external data source in SQL Server using PolyBase, configure a System DSN (CData SQL Analysis Services Sys is created automatically).

To connect, provide authentication and set the Url property to a valid SQL Server Analysis Services endpoint. You can connect to SQL Server Analysis Services instances hosted over HTTP with XMLA access. See the Microsoft documentation to configure HTTP access to SQL Server Analysis Services.

To secure connections and authenticate, set the corresponding connection properties, below. The data provider supports the major authentication schemes, including HTTP and Windows, as well as SSL/TLS.

  • HTTP Authentication

    Set AuthScheme to "Basic" or "Digest" and set User and Password. Specify other authentication values in CustomHeaders.

  • Windows (NTLM)

    Set the Windows User and Password and set AuthScheme to "NTLM".

  • Kerberos and Kerberos Delegation

    To authenticate with Kerberos, set AuthScheme to NEGOTIATE. To use Kerberos delegation, set AuthScheme to KERBEROSDELEGATION. If needed, provide the User, Password, and KerberosSPN. By default, the data provider attempts to communicate with the SPN at the specified Url.

  • SSL/TLS:

    By default, the data provider attempts to negotiate SSL/TLS by checking the server's certificate against the system's trusted certificate store. To specify another certificate, see the SSLServerCert property for the available formats.

You can then access any cube as a relational table: When you connect the data provider retrieves SSAS metadata and dynamically updates the table schemas. Instead of retrieving metadata every connection, you can set the CacheLocation property to automatically cache to a simple file-based store.

See the Getting Started section of the CData documentation, under Retrieving Analysis Services Data, to execute SQL-92 queries to the cubes.

Click "Test Connection" to ensure that the DSN is connected to SQL Analysis Services properly. Navigate to the Tables tab to review the table definitions for SQL Analysis Services.

Create an External Data Source for SQL Analysis Services Data

After configuring the connection, you need to create a master encryption key and a credential database for the external data source.

Creating a Master Encryption Key

Execute the following SQL command to create a new master key, 'ENCRYPTION,' to encrypt the credentials for the external data source.

CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'password';

Creating a Credential Database

Execute the following SQL command to create credentials for the external data source connected to SQL Analysis Services data.

NOTE: IDENTITY and SECRET correspond with the User and Password properties for SQL Analysis Services.

CREATE DATABASE SCOPED CREDENTIAL ssas_creds
WITH IDENTITY = 'username', SECRET = 'password';

Create an External Data Source for SQL Analysis Services

Execute the following SQL command to create an external data source for SQL Analysis Services with PolyBase, using the DSN and credentials configured earlier.

For SQL Analysis Services, set SERVERNAME to 'localhost' or '127.0.0.1' and leave PORT empty. PUSHDOWN is set to ON by default, meaning the ODBC Driver can leverage server-side processing for complex queries.

CREATE EXTERNAL DATA SOURCE cdata_ssas_source
WITH ( 
  LOCATION = 'odbc://SERVERNAME[:PORT]',
  CONNECTION_OPTIONS = 'DSN=CData SQL Analysis Services Sys',
  -- PUSHDOWN = ON | OFF,
  CREDENTIAL = ssas_creds
);

Create External Tables for SQL Analysis Services

After creating the external data source, use CREATE EXTERNAL TABLE statements to link to SQL Analysis Services data from your SQL Server instance. The table column definitions must match those exposed by the CData ODBC Driver for SQL Analysis Services. You can refer to the Tables tab of the DSN Configuration Wizard to see the table definition.

Sample CREATE TABLE Statement

The statement to create an external table based on a SQL Analysis Services Adventure_Works would look similar to the following:

CREATE EXTERNAL TABLE Adventure_Works(
  Fiscal_Year [nvarchar](255) NULL,
  Sales_Amount [nvarchar](255) NULL,
  ...
) WITH ( 
  LOCATION='Adventure_Works',
  DATA_SOURCE=cdata_ssas_source
);

Having created external tables for SQL Analysis Services in your SQL Server instance, you are now able to query local and remote data simultaneously. Thanks to built-in query processing in the CData ODBC Driver, you know that as much query processing as possible is being pushed to SQL Analysis Services, freeing up local resources and computing power. Download a free, 30-day trial of the ODBC Driver for SQL Analysis Services and start working with live SQL Analysis Services data alongside your SQL Server data today.