THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Alberto Ferrari

Visio and SQL Extended Properties: a tool to marry them

Visio database models have column descriptions, SQL Server has extended properties where to store them but, even if they share the same producer, it seems that Visio is unable to store column descriptions in extended properties so that other tools can gather the same information easily and produce a decent documentation of a database.

After some browsing on the web, I was unable to find a tool that let Visio save the table and column descriptions in SQL Server, so I decided it was time to code it by myself.

First you need to generate the DDL script of the database having DDL Script commens ON for all the columns (which can be configured in the driver options) as in the following picture:


In the DDL file, VISIO adds header of comments to each table like this:

/* Create new table "Sales.Dim_Customers".                                         */
/* "Sales.Dim_Customers" : Contains all the customer with various attributes used  */
/* to analyze them. Does not contain (bla bla bla)                                 */
/* "ID_Customer" : Primary key of the table                                        */
/* "CustomerCode" : Customer code as seen in the OLTP database                     */
/* "ID_Geography" : Key in Dim_Geography. It is not shown to the end user          */
/* "MaritalStatus" : Description of the marital status (Single / Married)          */
/* "Gender" : Description of the gender (Male, Female)                             */
... ... ...
create table "Sales.Dim_Customers" ( 
"ID_Customer" int identity not null,
"CustomerCode" nvarchar(15) not null,
"ID_Geography" int not null,
"MaritalStatus" nvarchar(20) not null,
"Gender" nvarchar(20) not null)


I have written a simple parser (GenerateExtendedAttrib) that looks for comments in this form in a DDL file (starting with "Create new table", then checks for column names and so on) and will finally generate the sp_addextendedproperty calls to define all the column and table descriptions.

The code fragment above generates this:

EXEC sys.sp_addextendedproperty 
    @value=N'Contains all the customer with various attributes used to analyze...' , 
EXEC sys.sp_addextendedproperty 
    @value=N'Primary key of the table' , 

You can call the utility with "/Append" in order to have the property definitions appended to the original file (which, in turn, can be run to have the database created) or you can call it without parameters, in this case the code is written to the console and you can redirect it wherever you want.

The tool can be downloaded at and is provided with sources (it is indeed a very simple yet effective gadget) so you can adapt it to whatever your needs are.

Have fun and, if you make any change to the code that might be useful, send me a note so I can update the public release.

Published Wednesday, November 7, 2007 12:00 PM by AlbertoFerrari
Filed under: ,



Mark said:

This tool sounds handy. Does your site ( still have it?

October 28, 2009 12:39 PM

AlbertoFerrari said:

Mark, is under maintenance in these days, if you drop me an e-mail at I'll send you the sources.

October 28, 2009 12:45 PM

Anibal Rodriguez said:


Could you please send me the sources please? my email is



January 4, 2010 2:25 PM

Wendell Sá said:


Please, send me this tool.



March 19, 2013 2:15 PM
New Comments to this post are disabled

About AlbertoFerrari

Alberto Ferrari is a Business Intelligence consultant. He his interests lie in two main areas: BI development lifecycle methodologies and performance tuning of ETL and SQL code. His main activities are with SSIS and SSAS for the banking, manufacturing and statistical sectors. He is also a speaker in international conferences like European PASS Conference and PASS Summit.
Privacy Statement