The M Code Behind the Power Query M function Teradata.Database

Teradata.Database is a built-in function in Power Query that allows users to connect to Teradata databases and retrieve data. The syntax of the function is as follows:

Teradata.Database(server as text, database as text, options as record) as table

The function takes three parameters: the server name, the database name, and an optional record of options. The server and database parameters are required, while the options parameter is optional. Let’s take a closer look at each of these parameters.

Server Parameter

The server parameter specifies the name of the Teradata database server that Power Query should connect to. This can be either the IP address or the fully qualified domain name of the server. If the server requires a specific port number, it can be specified by appending it to the server name using a comma, for example:


Database Parameter

The database parameter specifies the name of the Teradata database that Power Query should retrieve data from. This is typically the name of the database that contains the data you want to analyze.

Options Parameter

The options parameter is an optional record that specifies additional options for the Teradata.Database function. The available options are:

– Query: A SQL query to execute against the Teradata database. This can be used to retrieve specific data or to perform data transformations within the query itself.

– CommandTimeout: The number of seconds to wait for a command to complete before timing out. This can be useful if you are working with large datasets or slow database connections.

– ConnectionTimeout: The number of seconds to wait for a connection to the Teradata database to be established before timing out. This can be useful if you are working with remote databases or slow network connections.

– UseNativeQuery: A boolean value that specifies whether to use the Teradata native query engine instead of the default ODBC driver. This can be useful for improving performance or for working with specific Teradata features that are not supported by the ODBC driver.

Using Teradata.Database in Power Query

Now that we have a better understanding of the parameters of the Teradata.Database function, let’s take a look at how it can be used in Power Query.

First, open Excel or Power BI and navigate to the Power Query Editor. From here, select “From Database” in the “Get Data” section of the Home tab.

![Power Query Editor](https://i.imgur.com/yF1L4eF.png)

This will open the “From Database” dialog, where you can select the type of database you want to connect to. Select “Teradata Database” from the list and click “Connect”.

![From Database Dialog](https://i.imgur.com/FJ2DgqB.png)

This will open the “Teradata Database” dialog, where you can enter the server name, database name, and any additional options you want to use.

![Teradata Database Dialog](https://i.imgur.com/ALzJup6.png)

Once you have entered the required information, click “OK” to connect to the Teradata database. Power Query will retrieve the data from the specified database and display it in the Power Query Editor.

![Power Query Editor with Data](https://i.imgur.com/rk2sX5P.png)

From here, you can perform any necessary data transformations using the M language or the Power Query interface.

In this article, we have explored the M code behind the Power Query M function Teradata.Database. We have learned about the function’s parameters and options, and how it can be used to retrieve data from Teradata databases in Power Query. With this knowledge, you can now connect to your own Teradata databases and retrieve data for analysis in Excel or Power BI.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

10-12 Jul 23 (London or Online)
25-27 Sep 23 (London or Online)
20-22 Nov 23 (London or Online)

Contact Us


    Your Name (required)


    Email (required)


    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)