Skip to content

HexisData/sql-docs

Repository files navigation

sql-docs

HTML generator for SQL Server user-defined functions

Based on Phil Factor's https://www.simple-talk.com/sql/t-sql-programming/documenting-your-sql-server-database/

Files

  • documementationTemplate.html. Contains an HTML template, with {{tokens}} that get be replaced by the powershell script
  • generate.ps1. Set the parameters inside this file to conect to the right SQL Server instance. Run to generate HTML file.

Screenshot

Here is what the generated HTML looks like when run on a database with a single function (using the demo function dbo.IsPositive)

screenshot

How it works

Put a header on your function using very simple YAML syntax.

sql-docs produces an HTML document with information gleaned YAML headers combined with metadata from INFORMATION_SCHEMA.ROUTINES

Open generate.ps1 and set the variables $ServerName and $Database to point to your instance, then run generate.ps1

/**
summary:
  fnIsPositive returns true if both parameters are positive,
  and returns false otherwise
parameters:
  - name : num
    type: int
    description: any integer, positive or negative
    ifNull: fnIsPositive will return false, because NULL is not a positive number
  - name: num2
    type: int
    description: asdfsadf
    ifNull: nothing
author: rod3095
examples:
  - SELECT ajr.fnIsPositive(3)
  - SELECT ajr.fnIsPositive(-17)
  - SELECT ajr.fnIsPositive(NULL)
returns: 1 if @num is positive, 0 otherwise
**/

About

HTML generator for SQL Server user-defined functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published