Click here to Skip to main content
Click here to Skip to main content

Document SQL Server 2000/2005 Database

, 17 Oct 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
T-SQL script to generate the document of SQL 2000/2005 database


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.


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.


  • 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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Database Developer
United Kingdom United Kingdom
With 10 years of experience of working on Microsoft platform, currently I am working as Database/BI expert.

Comments and Discussions

GeneralMy vote of 5 Pinmemberthaidx8-Apr-13 19:18 
GeneralMy vote of 5 PinmemberBerBuz2-Dec-12 4:44 
GeneralMy vote of 5 Pinmemberformthis.com10-May-12 10:07 
GeneralMy vote of 5 PinmemberG.Suman Babu20-Apr-12 5:06 
QuestionVery good Article PinmemberG.Suman Babu20-Apr-12 5:05 
QuestionExcellent script Pinmembermickegus9-Feb-12 21:35 
QuestionGreat job! PinmemberPiotrZajac5-Feb-12 9:08 
GeneralMy vote of 5 PinmemberCassnat14-Dec-11 13:28 
QuestionFlippin Cool! PinmemberStewStyle13-Dec-11 0:06 
GeneralMy vote of 5 PinmemberBastiaans1-Jun-11 1:17 
General[My vote of 1] Thanks PinmemberMamun Reza30-May-11 19:44 
GeneralThanks! Pinmemberbougie4-May-11 4:45 
GeneralThanks PinmemberNayan S. Patel27-Apr-11 16:53 
GeneralMy vote of 5 Pinmemberkiran.puchakayala22-Apr-11 19:18 
GeneralThank you!! PinmemberMember 766559511-Feb-11 6:39 
GeneralThank you PinmembersamirMistry18-Oct-10 21:39 
GeneralThank you very much! .good job Pinmemberkoke171-Oct-10 1:40 
GeneralVery good work (PERFECT!!!) PinmemberAlbric3-Sep-10 0:47 
GeneralMy vote of 5 Pinmemberaivanq012-Sep-10 6:31 
GeneralAwesome script Pinmemberaivanq012-Sep-10 6:30 
GeneralMy vote of 4 PinmemberNArgade23-Aug-10 0:53 
GeneralThank You Pinmembersilverscouts9-Apr-10 16:24 
GeneralExcelent time saver [modified] 11:58 
GeneralAwesome! Just what I was looking for! Thanks! Pinmembermiguelguzman16-Feb-10 5:07 
GeneralVersion en Español con Procedimientos Almacenados para SQL Srv 2005 PinmemberRonald Fallas Rojas17-Dec-09 10:49 
GeneralRe: Version en Español con Procedimientos Almacenados para SQL Srv 2005 PinmemberRonald Fallas Rojas17-Dec-09 11:32 
QuestionAdd code for table-valued and scalar functions, and stored procedures? PinmemberTechVsLife21-Nov-09 18:06 
GeneralVery useful PinmemberBrianCharles20-Oct-09 9:45 
Generalbug report - column length doubled when using nvarchar/nchar Pinmembertsohr15-Sep-09 17:06 
GeneralExcellent!! Pinmembersksisme23-Jul-09 12:33 
GeneralExcellent job (stored procedure lister added) Pinmembergareth ashby24-Jun-09 0:02 
GeneralNice job! PinmemberDaveNoderer8-Jun-09 21:43 
GeneralThanks a lot - worked on SQL 2008 as well Pinmemberemadm30-Apr-09 11:49 
GeneralIs there any tool/utility which can generate the documentation from SQL Server 2005/2008 PinmemberAmit Chaudhary17-Apr-09 5:35 
GeneralGreat Work - Declare @Output nvarchar(4000) Pinmemberegphsharaf12-Apr-09 7:03 
GeneralRestore Sql 2005 database backup file in Sql server 2000 PinmemberParag Raibagkar30-Mar-09 1:13 
QuestionWhat a time saver! PinmemberDusty_e13-Mar-09 8:19 
GeneralThanks a lot PinmemberMember 476895525-Dec-08 11:02 
GeneralGreat Work PinmemberMark Harby30-Nov-08 13:05 
GeneralThanks! PinmemberShiscle14-Oct-08 23:40 
GeneralAppreciate Pinmemberadnawri28-Aug-08 19:11 
RantThanks Pinmembersoft_ghost25-Aug-08 0:26 
GeneralThanks! Pinmemberdr11020-Jul-08 12:29 
GeneralExcellent script. PinmemberUnserernst20-Jun-08 8:00 
GeneralThanks.. Pinmemberjames_davis_1210-Jun-08 11:07 
GeneralThank you, Pinmembersilverpilen2-May-08 5:37 
Generalwow.. PinmemberOkta Endy23-Apr-08 23:53 
GeneralExcelent!!! PinmemberMember 24919606-Apr-08 8:23 
GeneralThanks Pinmemberb minor6-Mar-08 4:40 
GeneralWow, thanks PinmemberThomas Wells4-Mar-08 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141220.1 | Last Updated 17 Oct 2009
Article Copyright 2008 by Nitinpatel
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid