---
title: "Using SQL File with Markup - 9.x and earlier"
canonical: "https://support.appfire.com/space/SUPPORT/89138855/Using%20SQL%20File%20with%20Markup%20-%209.x%20and%20earlier"
format: markdown
---
# Scenario

> Macro (div)
> 
> > Macro (inline-media-image)
> 
>  <span style="color: #999999">Estimated Time: 10</span>**<span style="color: #999999"> min</span>**<span style="color: #999999"> </span>

<span style="color: #000000">In this scenario, let's insert the </span>*<span style="color: #000000">SQL File</span>*<span style="color: #000000"> macro on a Confluence page by inserting</span> [Markup](https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html) <span style="color: #000000">from the menu. Our </span>*<span style="color: #000000">SQL File</span>*<span style="color: #000000"> macro</span><span style="color: #000000"> references a file containing SQL located within the </span>***<span style="color: #000000">/script</span>***<span style="color: #000000"> (default) directory of your Confluence server.</span>

## <span style="color: #000000">Background</span>

<span style="color: #000000">Our scenario uses a</span> data source profile,<span style="color: #000000"> </span>*<span style="color: #000000">BookWarehouse</span>*<span style="color: #000000">, to query a database table, </span>*<span style="color: #000000">BOOKS</span>*<span style="color: #000000">. The table contains the following columns and rows:</span>

```sql
SQL > select * from books;
+----+----------------------------+---------------------+-------+
| id | title                      | author              | price |
+----+----------------------------+---------------------+-------+
|  1 | The Grapes of Wrath        | John Steinbeck      | 12.99 |
|  2 | Nineteen Eighty-Four       | George Orwell       |  8.99 |
|  3 | The Wind-Up Bird Chronicle | Haruki Murakami     |  7.99 |
|  4 | Don Quixote                | Miguel De Cervantes | 29.99 |
|  5 | Pilgrims Progress          | John Bunyan         | 17.99 |
|  6 | Robinson Crusoe            | Daniel Defoe        | 29.05 |
|  7 | Gullivers Travels          | Jonathan Swift      | 15.98 |
|  8 | Tom Jones                  | Henry Fielding      | 13.59 |
|  9 | Clarissa                   | Samuel Richardson   | 13.59 |
| 10 | Tristram Shandy            | Laurence Sterne     |  7.59 |
+----+----------------------------+---------------------+-------+
```

> ℹ️ <span style="color: #000000">For information about data source profiles, refer to:</span>
> ℹ️ 
> ℹ️ - [Data source profiles](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74323164/Configure+Data+Source+Profiles+-+9.x) <span style="color: #000000">for 9.x versions</span>
> ℹ️ - [Data source profiles](https://appfire.atlassian.net/wiki/x/6xNuB) <span style="color: #000000">for 8.x versions</span>

<span style="color: #000000">Our query is stored within a file called </span>*<span style="color: #000000">books.sql</span>*<span style="color: #000000"> and along with our Confluence administrator to place it within the </span>***<span style="color: #000000">/script</span>***<span style="color: #000000"> (default) directory on our Confluence server. Our query looks like:</span>

```sql
SELECT title as "Title", author as "Author", price as "Retail Price" FROM books WHERE price < 30 ORDER BY title;
```

## <span style="color: #000000">Steps</span>

<span style="color: #000000">The following steps demonstrates how to use Markup to insert the </span>*<span style="color: #000000">SQL File</span>*<span style="color: #000000"> macro</span><span style="color: #000000"> on a Confluence page:</span>

> Macro (table-plus)
> 
> |  |  |  |
> | --- | --- | --- |
> | ![image](media://700f4734-9f89-4124-b005-dd90b6a5f9ad) | ## <span style="color: #000000">Create Confluence page</span><br><span style="color: #000000">Create a Confluence page to add the </span>*<span style="color: #000000">SQL File</span>*<span style="color: #000000"> macro needed to list out your books.</span><br>1. <span style="color: #000000">Create a page named</span>***<span style="color: #000000"> Classic Books </span>***<span style="color: #000000">in a space accessible to the desired audience.</span>
> 2. <span style="color: #000000">Click </span>**<span style="color: #000000">Save</span>**<span style="color: #000000"> to save the new page.</span> |  |
> | --- |
> | ![image](media://44b9afe6-bd61-4fe0-a472-236235081bdd) | ## <span style="color: #000000">Insert the </span>*<span style="color: #000000">SQL File</span>*<span style="color: #000000"> macro using the Insert Markup Menu</span><br><span style="color: #000000">Edit the </span>*<span style="color: #000000">Classic Books</span>*<span style="color: #000000"> page and:</span><br>1. <span style="color: #000000">Select </span>**<span style="color: #000000">Insert Markup</span>**<span style="color: #000000"> from the top menu.</span>
> 2. <span style="color: #000000">Type the following into the editor window. Note the </span>*<span style="color: #000000">dataSource</span>*<span style="color: #000000"> name and file name referenced: </span>
> 3. <span style="color: #000000">Click </span>**<span style="color: #000000">Insert</span>**<span style="color: #000000"> to insert your Markup within the page.</span>
> 4. <span style="color: #000000">Click </span>**<span style="color: #000000">Save </span>**<span style="color: #000000">to save your page and view your results.</span><br>## <span style="color: #000000">Alternative:</span><br>> Macro (nested-table) | **How to insert Markup from the menu**<br>![image](media://a6626935-a52f-4aab-991f-277b55fe989c)<br>![image](media://2fb9f667-0313-47b3-abb7-0fe4aac6e923) |

## <span style="color: #000000">Explore Tutorials</span>

<span style="color: #000000">We've prepared a number of</span> [tutorials](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74322767/Tutorials)<span style="color: #000000"> which demonstrates how to use our </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macros with the native </span>*<span style="color: #000000">Chart</span>*<span style="color: #000000"> macro.</span>