USING PLACEHOLDERS

Dynamic results in your output

You can use placeholders in AutoSQL to make your email messages or filenames use variables like date, time, the number of results rows, or even a part of the result itself.

A common example is to use the {date} and {time} place holder in the output filename. Instead of overwriting the same file every day, this will create a new one each time. This way you can also save the history of queries.

Fields which can have placeholders

  • Name of the output file
  • Subject of the email
  • Message text of the email

By right clicking in a field you see the available placeholders:

Available placeholders

Clicking one of the options will insert it in the text.

Different date and time format in filenames

The output path is limited to {date}, {date-1} and {time}. Actually also the format is different. Normally the dates and times are outputted in the regional settings format of the OS. However, for the output filename the date is always outputted as YYYYMMDD and time as HHMMSS.

An example of using placeholders

Below you see a screenshot of an action file where a lot of place holders are used:

Results in the email body

Possible place holder details

Most placeholders are straight forward, but below you’ll find a detailed explanation.

{result:10}

This will put in a table with the first 10 rows of the result in the email message, this can be used to preview the complete result set or even to have the full in there if you know the number of rows are limited. You can change the 10 into any number of maximum lines, but be carefull. If the message becomes too large, it might not be accepted by your email provider.

An examples output in Gmail:

Results in the email body

{date} and {date-1} and {date:«formatter»}

The {date} placeholder will always put in the current date. However, if you run the report with data of yesterday, you can also subtract a day with the -1 addition: {date-1} will always print the date of yesterday. Actually you can also get tomorrow with {date+1} and replace the 1 with any number. Eg to print the date of 7 days ago you can use {date-7}.

You can also add an optional formatter. Eg {date-1:MMMM-yy}, which will result in the full month name and the last two digits of the year (June-2026). The exact result also depends on the regional settings of the server you are running AutoSQL on. All possible formatting options are documented here: https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

You can also use this in the Excel sheet name. This way you could automatically create sheets per month.

{time}

Outputs the time the query was ran.

{rows}

Outputs the number of rows in the result set of the query.

{output path}

Inserts the complete path to the output file. Especially when a placeholder was also used in the filename this can be useful to provide a link. Eg when you output the query to a network drive a user can copy the path to access it directly and you don’t need to attach it.

{action}

Outputs the name of the action.

{query}

Output the SQL query that was executed.

{cell:<row>:<column>:<default value>}

Replaces with the value of cell at row and column. In case this does not exist, you can specify the optional default value. Example: {cell:1:5:not found}. This will take the 5th column value of the first row. If this does not exist, it will replace with ‘not found’.