A utility for developers to generate Markdown documentation from SQL Server (MSSQL) database objects such as views, stored procedures, table-valued functions, and triggers. The generated .md files can be used as knowledge artifacts in tools like ChatGPT's Knowledge or Confluence documentation.
- Extract definitions of:
- SQL Views
- Stored Procedures
- Table-Valued Functions
- Triggers
- Generate clean, structured Markdown documentation
- Summary tables with links to detailed definitions
- Easy integration with documentation platforms
Make sure you have UV installed on your system.
uv sync
- procedure_definitions.csv (Procedure Name, Procedure Definition)
- view_definitions.csv (View Name, View Definition)
- function_definitions.csv (Function Name, Function Definition)
- trigger_definitions.csv (Trigger Name, Trigger Definition)
The script generates the following Markdown files:
- procedure_definitions_documentation.md
- view_definitions_documentation.md
- table_valued_function_definitions.md
- trigger_definitions_documentation.md
Each file includes:
- Summary table with indexed object names
- SQL definition block for each object
Run these queries in SQL Server Management Studio (SSMS) to extract object definitions and save them as CSV or text files.
SELECT p.name AS [Procedure Name], m.definition AS [Procedure Definition]
FROM sys.procedures p
JOIN sys.sql_modules m ON p.object_id = m.object_id;
SELECT v.name AS [View Name], m.definition AS [View Definition]
FROM sys.views v
JOIN sys.sql_modules m ON v.object_id = m.object_id;
SELECT o.name AS [Function Name], m.definition AS [Function Definition]
FROM sys.objects o
JOIN sys.sql_modules m ON o.object_id = m.object_id
WHERE o.type = 'TF';
SELECT t.name AS [Trigger Name], m.definition AS [Trigger Definition]
FROM sys.triggers t
JOIN sys.sql_modules m ON t.object_id = m.object_id;
Once your CSVs are prepared, run the script:
uv run generate_markdown.py
The Markdown files will be generated in your working directory.
Pull requests are welcome! Feel free to open issues to discuss improvements or new features.
This project is licensed under the MIT License.