Click here to Skip to main content
Licence CPOL
First Posted 31 Mar 2008
Views 30,911
Downloads 515
Bookmarked 16 times

Generating Data Dictionary or Database Design Document using MS Word Macros

By | 31 Mar 2008 | Article
Generating Data Dictionary or Database Design Document using MS Word Macros

Introduction

Manually preparing data dictionary document will take ages in MS Word which contains 100's of tables, stored procedures, functions, triggers, views, indexes, etc. in the SQL Server database as you need to type each and every column of the table along with the associated dependencies. I need a data dictionary document which generates the database schema automatically in one click with nicely formatted. For this I did lot of research in Google to find the solution and finally I have wrote my own code to do this functionality and i thought to share my experience with you all.

The main purpose of this article is to generate the data dictionary document automatically by simply running the macro code in MS Word with in seconds.

I am not a guru of VBA but still started doing some kind of researching on VBA code in Google then I got ideas from different forums and many thanks to those people who posted their ideas.

I hope this solution will help you to prepare the data dictionary document. Here we start...

Basically, this code will prepare you the following information in the document

Table name with the following dependent information.

· Table Column Details
· Indexes
· Views
· Stored Procedures
· Functions
· Triggers
· Primary Keys
· Foreign Keys
· Default Constraints
· Identity Columns

Using the code

Following are the steps to run this code:

1. Simply open a blank word document (it is mandatory).

2. Go to menu Tools->Macro->Macros->Create then this will create a new visual basic module editor.

3. Paste this code.

4. Change the connection string as per your SQL Server credentials (it is mandatory).

5. Add the references of Microsoft Active X Data Objects Library from the menu Tools->References

6. Run the macro by pressing F5 from VBA editor.

Document_Template.JPG

Points of Interest

This code will generate the data dictionary document automatically with one click and it is simple to use this code.

History

Keep a running update of any changes or improvements you've made here.

License

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

About the Author

Shashidhar Rao Nellutla

Software Developer (Senior)

United Kingdom United Kingdom

Member

Completed Masters in Computer Applications.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionvery nice tool Pinmemberharsh.programmer0:35 22 Feb '12  
Questionfor non VB developers PinmemberMember 852727119:07 29 Dec '11  
GeneralThanks Pinmembersreelekhamenon14:07 8 Dec '10  
Generalthanks Pinmembervelpetit18:06 9 Dec '09  
Generalole db PinmemberSvetlana Tipping22:38 18 Feb '09  
GeneralWord 2007 PinmemberMember 21710098:09 17 Jun '08  
GeneralMacro not working Pinmemberniranjan singh3:15 14 Apr '08  
GeneralRe: Macro not working Pinmembergrom_boy23:36 14 Apr '08  
GeneralRe: Macro not working [modified] PinmemberAndrewGail5:12 24 Apr '08  
I tried this as well, unfortunately sys.tables is SQL Server 2005, not 2000.
 
I'll try it on our development 2K5 server and see if it works, if not I'll look at changing it to work with SQL 2000 sysobjects e.g.
SELECT * FROM dbo.sysobjects WHERE xtype = 'u' ORDER BY Name
 
Edit: Tried it on a SQL 2K5 server and it appears to do nothing??? No errors at all, weird...
Will have a go at modding the code to work with SQL 2000 and see how that fairs.
 
modified on Thursday, April 24, 2008 11:27 AM

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.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120529.1 | Last Updated 31 Mar 2008
Article Copyright 2008 by Shashidhar Rao Nellutla
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid