Skip to content

Microsoft SQL Server Microsoft SQL Server: Running Select Queries

Summary

This page explains how PPA outputs data from MSSQL select queries.

When you use the select action:

  • The output is a list of dictionaries
  • Each dictionary is a database record
  • The keys of each dictionary will be the selected column names
  • Each key's value will be the corresponding record field

Column Names

The column names will be taken directly from the SQL Query.

Any aliased columns containing spaces will have those spaces replaced with an underscore.

Special Functions

If the query is a special function (like SELECT @@VERSION), the column name will be missing_column_name.

Example

  • Running a select query with column name aliases
  • Saving the output as a variable called users

Select Action

1
2
3
4
5
6
- mssql.client.select:
    query: >
      SELECT first_name AS "First Name", last_name AS "Last Name" FROM users
  load:
    mssql: mssql_secrets
  save: users

The structure of each record in users will be:

Action Output

1
2
- First_Name: John
  Last_Name: Smith

Datetime Columns

All datetime fields are automatically converted to date strings in the following format:

10:06:38 20/06/2020