Paste any SQL query, stored procedure, or view. Get structured technical documentation — tables, columns, data lineage, step-by-step logic — in seconds.
Input: a CTE with a window function. Output: complete technical documentation, ready to paste into Confluence or commit to your repository.
## Query Purpose Retrieves the top 10 customers ranked by total revenue from completed orders, using a CTE to pre-aggregate sales data and a window function to compute the ranking. ## Tables & Objects Referenced | Object | Schema | Type | Role in Query | |--------|--------|------|---------------| | orders | dbo | Table | Source of transaction data | | customers | dbo | Table | Customer master data | | SalesSummary | — | CTE | Aggregated revenue per customer | ## Column Descriptions | Column | Source | Description | |--------|--------|-------------| | customer_id | orders | Foreign key linking orders to customers | | total_revenue | SalesSummary (derived) | Sum of completed order amounts per customer | | order_count | SalesSummary (derived) | Number of completed orders per customer | | rank | Computed | Revenue rank across all customers (1 = highest) | ## Query Logic — Step by Step 1. **CTE SalesSummary:** Filters orders with status = 'completed', then groups by customer_id to compute total revenue and order count. 2. **Main SELECT:** Joins customers with SalesSummary on customer ID to enrich results with customer name. 3. **RANK():** Assigns a revenue rank using a window function ordered by total_revenue descending. 4. **LIMIT 10:** Returns only the top 10 ranked customers. ## Data Lineage orders (amount, status) → SalesSummary (total_revenue, order_count) → Final result (enriched with customers.name) ## Usage Notes - Requires completed orders to exist; returns empty if no completed orders match. - RANK() produces gaps for ties; use DENSE_RANK() if gap-free ranking is required.
DocGen doesn't just describe what a query does — it explains why, maps the data flow, and produces output your team can actually use.
Every table, view, and CTE is identified and described. Each column gets a plain-English explanation of what it stores and why it matters.
Traces how data flows from source tables through transformations to the final output. Essential for impact analysis and compliance.
Breaks down complex queries into numbered steps — CTEs, JOINs, window functions, subqueries — explained in the order they execute.
Output is structured Markdown with tables. Paste directly into Confluence, Notion, GitHub, or your internal wiki — zero formatting needed.
A stored procedure that would take 45 minutes to document manually takes 8 seconds with DocGen. Run it before every code review.
New team members understand an unfamiliar codebase in hours instead of weeks. DocGen turns tribal knowledge into written documentation.
Generate documentation for the query under review so reviewers understand intent before reading the code.
Document the 20 most critical stored procedures in your codebase in under 10 minutes.
Produce data lineage documentation showing exactly which tables feed which reports — required for GDPR and SOX audits.
Before leaving a project, run DocGen on all your queries and commit the output to the repository.
Yes. Paste the full CREATE PROCEDURE or CREATE VIEW statement and DocGen will document all parameters, logic, and dependencies.
The output is structured Markdown. You can copy and reformat it as needed. Export to PDF is on the roadmap.
Yes. DocGen is trained on enterprise T-SQL patterns including CTEs, window functions, MERGE statements, dynamic SQL, and SQL Server-specific functions.
Create a free account to run DocGen on your own queries.
Sign in to run DocGen on your own SQL queries. 3 free uses — no credit card required.
Start free3 free uses after registration. No credit card required.
Start free