TSQL scripts for optimizing storage, documentation, and general administrative needs.

View the Project on GitHub LowlyDBA/ExpressSQL


License SQL Server Azure SQL

Build status GitHub Workflow Status (branch) codecov


You wouldn't code without comments, so why database without them?

Databases can be complex, disastrous things. Not every database admin, developer, or analyst has the time to learn the ins and outs of a database in order to just do their work. To make things worse, few products and fewer free options exist to help present databases in a human readable format.

sp_doc's goal is to generate on the fly database documentation in markdown. This means you now have a free and extensible selfdocumenting database! By building the tool in TSQL, the documenting process can remain simple, secure, require no additional infrastructure, and avoid red tape that third party applications often require.

It documents:

and plays nice with:



The primary parameter for this procedure is a database name, since the primary scenario for this is to be included in a utility or system database:

>    EXEC dbo.sp_doc @DatabaseName = 'WideWorldImporters'

An alternative key for extended property values can also be specified to override the default of Description:

>    EXEC dbo.sp_doc @DatabaseName = 'WideWorldImporters', @ExtendedPropertyName = 'MS_Description';

To prevent data truncation, unwanted headers, etc. it should be called via sqlcmd, outputting directly to a file:

    sqlcmd *S localhost *d master *Q "exec sp_doc @DatabaseName = 'WideWorldImporters';" *o *y 0


Output for the WideWorldImporters database.

Note: Slight changes may be made to this database to better demo script capabilities.


Missing a feature? Found a bug? Open an issue to get some :heart:.


Check out the other scripts in the Express SQL Suite.