Sql Server

Creating Markdown reports from SQL Server queries


Markdown is a lightweight markup language with plain-text-formatting syntax. It’s is often used for formatting simple readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor. You can read more on this link: https://daringfireball.net/projects/markdown/.

Sometimes I need simple reports from my SQL Server queries and put it on some wiki pages, SharePoint portals, GitHub documentation pages or similar. Markdown simple document format is very suitable for this kind of purposes. By focusing more on the content I can still apply minimalistic formatting on the document.

In the next section, I will show how I can create simple Markdown reports from T-SQL queries.

Commonly, SQL queries return tabular data structures. Therefore, I will show how to wrap SQL query inside Markdown table definition.

Some tips and tricks

Before extracting the data from the SQL Server and present it as a markdown document, I just need to do some little tricks with T-SQL or on SSMS query options.

The most common tool for any SQL Developer is SQL Server Management Studio IDE (SSMS). There are, of course, also other ways how to get the data from SQL Server – but as I said – SSMS is the most commonly used tool for handling SQL data manipulation or administration.

Let’s take a look on these tricks.

Result to Text

For better experience, I recommend to display data as a text output. You do this in Query options in SSMS by hitting Ctrl+T or via menu Query/Results To/Results To Text.


To exclude “rows affected” text at the end of every query result I need to SET NOCOUNT OFF” in my T-SQL, e.g.


Disable displaying “Show completion time” option

If I want to rid of “Completion time” text at the end of the query processing I need to uncheck my query option “Show completion time“, e.g.


Disable “Include column headers in the result set” option

To remove header separator in SSMS Text output I need to uncheck “Include column headers in the result set“, e.g.


It would be really awesome, if I could control all these output parameters via T-SQL, but I guess this is not possible.

If someone has some ideas how this can be done, please put comments below this blog post.

Anyway, when everything is set, I can execute my query and I get this output.

My Markdown report is ready. I can upload it to some portal which can consume and display Markdown document. For example, I will show how my MD document looks in GitHub preview.


Nice, right?


In this blog post, I showed how to wrap T-SQL queries to generate simple Markdown reports.

Especially tabular forms are very interesting here, because this kind of structures are the most common ones.

If you find this approach useful, or you have any comment, please put some comments bellow.

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.