65.9K
CodeProject is changing. Read more.
Home

Document SQL Server 2000/2005 Database

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.83/5 (100 votes)

Feb 4, 2008

CPOL

1 min read

viewsIcon

253435

downloadIcon

27166

T-SQL script to generate the document of SQL 2000/2005 database

Introduction

Here is the script to generate the HTML document of your SQL Server 2000/2005 database. It is reverse engineering after the database is created. I hope it will be useful to many of you.

Background

While working as a part time DBA for some projects, I encountered difficulties in documenting and publishing my databases because I do not have any tool available to generate the document. I have written this script that gives the output in HTML that is easy to be modified/published/distributed.

Using the Code

Follow these steps to use this script:

  • Download the attached script file and open it in Management Studio (tested on version 9.00).
  • Select the database for which you want to generate document.
  • Select Result to File (Ctrl+Shift+F) from Query - Results To menu.
  • Execute (F5) the script.
  • In the Save Result dialogue box, type a file name (filename.htm/filename.html) in the File Name text box and select All Files (*.*) in Save As Type dropdown.
  • After successful execution of query, check the output file.

Note: For populating the description of table and columns, update the Description property of table and columns while creating database diagram or add extended property for them with name as MS_Description.

I hope this information will be helpful. I am planning to provide details of code in my next update.

Updates

  • Bug in getting index column is resolved
  • Bug in getting check constraints list is resolved
  • Definition of check constraints is added to document
  • Table Summary is changed to Table Description
  • Table and column description is populated from extended property

Download documentation application from here.