Click here to Skip to main content
13,594,656 members
Click here to Skip to main content
Add your own
alternative version


114 bookmarked
Posted 3 Feb 2008
Licenced CPOL

Document SQL Server 2000/2005 Database

, 17 Oct 2009
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

AnswerRe: Where is the Description? Pin
Nitinpatel18-Feb-08 2:28
memberNitinpatel18-Feb-08 2:28 
GeneralExcellent work Pin
SleepyCrat12-Feb-08 3:33
memberSleepyCrat12-Feb-08 3:33 
GeneralRe: Excellent work Pin
Nitinpatel18-Feb-08 2:29
memberNitinpatel18-Feb-08 2:29 
GeneralVery useful Pin
Vikas Mehta12-Feb-08 3:13
memberVikas Mehta12-Feb-08 3:13 
GeneralVery good indeed Pin
crchambers144212-Feb-08 1:23
membercrchambers144212-Feb-08 1:23 
GeneralRe: Very good indeed Pin
Nitinpatel17-Feb-08 21:52
memberNitinpatel17-Feb-08 21:52 
GeneralRe: Very good indeed Pin
rjf6061817-Jul-08 5:06
memberrjf6061817-Jul-08 5:06 
QuestionExcellent script thanks! Pin
PKBoone12-Feb-08 0:47
memberPKBoone12-Feb-08 0:47 
Really good work.

I do however have one question. Why do the column descriptions not get shown? I searched in SQL Server to try and find the answer but could not... I couldn't even find where the column descriptions get stored. I took a look in the master table 'sp_help' stored procedure as it also will not show the column descriptions... but to no avail... it just has a remark in it that the description is NULL.. but they are not. I mean I took the time to enter them so they should be accessible.. don't you think?

I do know this, if you create a diagram then the column descriptions will be shown, and can even be edited right in the diagram.

Thanks again.

P.S. just one more thing Smile | :)

it would also be really nice and cool, if stored procedures would get listed. and also maybe even a link to the code of the stored procedure.
GeneralRe: Excellent script thanks! Pin
Nitinpatel17-Feb-08 21:51
memberNitinpatel17-Feb-08 21:51 
GeneralRe: Excellent script thanks! Pin
PKBoone17-Feb-08 22:10
memberPKBoone17-Feb-08 22:10 
GeneralRe: Excellent script thanks! Pin
Nitinpatel17-Feb-08 23:32
memberNitinpatel17-Feb-08 23:32 
GeneralI like it Pin
don!marco11-Feb-08 21:51
memberdon!marco11-Feb-08 21:51 
GeneralRe: I like it Pin
Nitinpatel17-Feb-08 21:45
memberNitinpatel17-Feb-08 21:45 
GeneralThanks! Pin
AWar11-Feb-08 20:16
memberAWar11-Feb-08 20:16 
Generalvery nice Pin
Ali Mojtabaee8-Feb-08 2:47
memberAli Mojtabaee8-Feb-08 2:47 
GeneralExcelent!!! Pin
Member 16448487-Feb-08 10:26
memberMember 16448487-Feb-08 10:26 
GeneralAldo Pin
Member 36218625-Feb-08 3:57
memberMember 36218625-Feb-08 3:57 
GeneralVery good work Pin
Sabarinathan Arthanari4-Feb-08 18:45
memberSabarinathan Arthanari4-Feb-08 18:45 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04-2016 | 2.8.180621.3 | Last Updated 17 Oct 2009
Article Copyright 2008 by Nitinpatel
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid