Click here to Skip to main content
11,803,019 members (62,213 online)
Click here to Skip to main content

Document SQL Server 2000/2005 Database

, 17 Oct 2009 CPOL 161.4K 26.8K 111
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.

You may also be interested in...

Comments and Discussions

General[My vote of 1] Thanks Pin
Mamun Reza30-May-11 18:44
memberMamun Reza30-May-11 18:44 
GeneralThanks! Pin
bougie4-May-11 3:45
memberbougie4-May-11 3:45 
GeneralMy vote of 5 Pin
kiran.puchakayala22-Apr-11 18:18
memberkiran.puchakayala22-Apr-11 18:18 
GeneralThank you!! Pin
Member 766559511-Feb-11 5:39
memberMember 766559511-Feb-11 5:39 
GeneralThank you Pin
samirMistry18-Oct-10 20:39
membersamirMistry18-Oct-10 20:39 
GeneralThank you very much! .good job Pin
koke171-Oct-10 0:40
memberkoke171-Oct-10 0:40 
GeneralVery good work (PERFECT!!!) Pin
Albric2-Sep-10 23:47
memberAlbric2-Sep-10 23:47 
GeneralMy vote of 5 Pin
aivanq012-Sep-10 5:31
memberaivanq012-Sep-10 5:31 
GeneralAwesome script Pin
aivanq012-Sep-10 5:30
memberaivanq012-Sep-10 5:30 
GeneralMy vote of 4 Pin
NArgade22-Aug-10 23:53
memberNArgade22-Aug-10 23:53 
GeneralThank You Pin
silverscouts9-Apr-10 15:24
membersilverscouts9-Apr-10 15:24 
GeneralExcelent time saver [modified] Pin 10:58 10:58 
GeneralAwesome! Just what I was looking for! Thanks! Pin
miguelguzman16-Feb-10 4:07
membermiguelguzman16-Feb-10 4:07 
GeneralVersion en Español con Procedimientos Almacenados para SQL Srv 2005 Pin
Ronald Fallas Rojas17-Dec-09 9:49
memberRonald Fallas Rojas17-Dec-09 9:49 
GeneralRe: Version en Español con Procedimientos Almacenados para SQL Srv 2005 Pin
Ronald Fallas Rojas17-Dec-09 10:32
memberRonald Fallas Rojas17-Dec-09 10:32 
QuestionAdd code for table-valued and scalar functions, and stored procedures? Pin
TechVsLife21-Nov-09 17:06
memberTechVsLife21-Nov-09 17:06 
GeneralVery useful Pin
BrianCharles20-Oct-09 8:45
memberBrianCharles20-Oct-09 8:45 
Generalbug report - column length doubled when using nvarchar/nchar Pin
tsohr15-Sep-09 16:06
membertsohr15-Sep-09 16:06 
GeneralExcellent!! Pin
sksisme23-Jul-09 11:33
membersksisme23-Jul-09 11:33 
GeneralExcellent job (stored procedure lister added) Pin
gareth ashby23-Jun-09 23:02
membergareth ashby23-Jun-09 23:02 
GeneralNice job! Pin
DaveNoderer8-Jun-09 20:43
memberDaveNoderer8-Jun-09 20:43 
GeneralThanks a lot - worked on SQL 2008 as well Pin
emadm30-Apr-09 10:49
memberemadm30-Apr-09 10:49 
GeneralIs there any tool/utility which can generate the documentation from SQL Server 2005/2008 Pin
Amit Chaudhary17-Apr-09 4:35
memberAmit Chaudhary17-Apr-09 4:35 
GeneralGreat Work - Declare @Output nvarchar(4000) Pin
egphsharaf12-Apr-09 6:03
memberegphsharaf12-Apr-09 6:03 
GeneralRestore Sql 2005 database backup file in Sql server 2000 Pin
Parag Raibagkar30-Mar-09 0:13
memberParag Raibagkar30-Mar-09 0:13 
QuestionWhat a time saver! Pin
Dusty_e13-Mar-09 7:19
memberDusty_e13-Mar-09 7:19 
GeneralThanks a lot Pin
Member 476895525-Dec-08 10:02
memberMember 476895525-Dec-08 10:02 
GeneralGreat Work Pin
Mark Harby30-Nov-08 12:05
memberMark Harby30-Nov-08 12:05 
GeneralThanks! Pin
Shiscle14-Oct-08 22:40
memberShiscle14-Oct-08 22:40 
GeneralAppreciate Pin
adnawri28-Aug-08 18:11
memberadnawri28-Aug-08 18:11 
RantThanks Pin
soft_ghost24-Aug-08 23:26
membersoft_ghost24-Aug-08 23:26 
GeneralThanks! Pin
dr11020-Jul-08 11:29
memberdr11020-Jul-08 11:29 
GeneralExcellent script. Pin
Unserernst20-Jun-08 7:00
memberUnserernst20-Jun-08 7:00 
GeneralThanks.. Pin
james_davis_1210-Jun-08 10:07
memberjames_davis_1210-Jun-08 10:07 
GeneralThank you, Pin
silverpilen2-May-08 4:37
membersilverpilen2-May-08 4:37 
Generalwow.. Pin
Okta Endy23-Apr-08 22:53
memberOkta Endy23-Apr-08 22:53 
GeneralExcelent!!! Pin
Member 24919606-Apr-08 7:23
memberMember 24919606-Apr-08 7:23 
GeneralThanks Pin
b minor6-Mar-08 3:40
memberb minor6-Mar-08 3:40 
GeneralWow, thanks Pin
Thomas Wells4-Mar-08 6:20
memberThomas Wells4-Mar-08 6:20 
GeneralComming up with newer versions... Pin
virtualleye28-Feb-08 17:49
membervirtualleye28-Feb-08 17:49 
GeneralAmazing Work. Pin
Dipak V Bava28-Feb-08 17:25
memberDipak V Bava28-Feb-08 17:25 
GeneralRe: Amazing Work. Pin
Nitinpatel28-Feb-08 22:07
memberNitinpatel28-Feb-08 22:07 
GeneralRe: Amazing Work. Pin
Dipak V Bava6-Mar-09 4:34
memberDipak V Bava6-Mar-09 4:34 
Generalthanx Pin
KINGCHEMICAL25-Feb-08 18:30
memberKINGCHEMICAL25-Feb-08 18:30 
GeneralAdd like from fk column to referenced table Pin
gilad12325-Feb-08 0:44
membergilad12325-Feb-08 0:44 
GeneralNice Script Pin
esolomonidis18-Feb-08 8:58
memberesolomonidis18-Feb-08 8:58 
GeneralExcellent work! Pin
sys2matk18-Feb-08 7:28
membersys2matk18-Feb-08 7:28 
GeneralCool Quesry!!!! Pin
alex_kl18-Feb-08 5:58
memberalex_kl18-Feb-08 5:58 
GeneralGreat! But... Pin
PKV113-Feb-08 1:22
memberPKV113-Feb-08 1:22 
GeneralRe: Great! But... Pin
Nitinpatel17-Feb-08 22:55
memberNitinpatel17-Feb-08 22:55 

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
Web03 | 2.8.151002.1 | Last Updated 17 Oct 2009
Article Copyright 2008 by Nitinpatel
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid