30.06.2013 Views

SQL Server Team-based Development - Red Gate Software

SQL Server Team-based Development - Red Gate Software

SQL Server Team-based Development - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2: Documenting your Database<br />

to code, the same is not true of tables in <strong>SQL</strong> <strong>Server</strong>. When you script out a table in<br />

SSMS, or via SMO, you'll notice that table build scripts have lost any comments that you<br />

put in them.<br />

This may or may not present a problem. It depends on how you develop databases. There<br />

are two basic ways of developing databases: one, where the script is the primary source,<br />

and the other, where the database is considered to be the source. If you are doing the<br />

former, and you run a fiendishly clever source-control system, then you don't have a<br />

problem, but otherwise, you will have to put your structured header in an "extended<br />

property" of the table.<br />

The first method of developing databases involves maintaining one or more build scripts<br />

which contain all the comment blocks and inline comments. This is used to generate the<br />

database, but the process is never reversed. The second method avoids the meticulous<br />

source-control systems that the script-<strong>based</strong> method involved. The current version of<br />

the development database effectively becomes the source, and the state of the database is<br />

"pulled off" at regular intervals as a build script, using SMO or a third-party tool, such as<br />

<strong>SQL</strong> Compare. Each developer alters a database routine by first scripting off the routine<br />

he is working on using SSMS.<br />

If you use the latter method of developing databases, then you have to use extended<br />

properties to store your header information, rather than storing it with the code itself, in<br />

the header.<br />

Extended properties<br />

There are problems in using extended properties as an alternative to headers, because<br />

GUIs generally only allow access to the ones that are used by SSMS, and that boils down<br />

to one extended property called MS_Documentation. This, by itself, isn't enough.<br />

Even if you define extra properties to store different types of information, you still face<br />

problems with lists, such as revision lists, since one cannot have more than one instance<br />

48

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!