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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

57<br />

Chapter 2: Documenting your Database<br />

ALTER PROCEDURE ExtractDocumentation<br />

/**<br />

summary: ><br />

Gets the source of every routine in the database and extracts the header<br />

files from them, and then parses the YAML file to extract a relational table<br />

with all the information.<br />

Revisions:<br />

– version : 1<br />

Modification: Created the procedure<br />

Author : Phil Factor<br />

Date : 01/10/2010<br />

example:<br />

– code: ><br />

returns: ><br />

The documentation table<br />

*/<br />

AS<br />

DECLARE @documentation TABLE<br />

(<br />

[object_type] VARCHAR(32) ,<br />

[schema] SYSNAME ,<br />

[object_name] SYSNAME ,<br />

[sequence_ID] INT ,<br />

[path] VARCHAR(255) ,<br />

[attribute] VARCHAR(255) ,<br />

[sequence] VARCHAR(255) ,<br />

[value] VARCHAR(MAX)<br />

)--the table to take the documentation items<br />

DECLARE @allObjects TABLE<br />

(<br />

TheID INT IDENTITY(1, 1) ,<br />

[object_type] VARCHAR(32) ,<br />

[schema] SYSNAME ,<br />

[object_name] SYSNAME ,<br />

[definition] VARCHAR(MAX)<br />

)- – the table containing all the objects<br />

DECLARE @Definition VARCHAR(MAX) ,<br />

@Header VARCHAR(MAX) ,--what is in the header information<br />

@Object_name SYSNAME ,--the object name<br />

@schema SYSNAME ,--the schema<br />

@Object_type VARCHAR(32) ,--the type of object<br />

@ii INT ,--iteration counter<br />

@iiMax INT – -max value of iteration counter<br />

INSERT INTO @AllObjects

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

Saved successfully!

Ooh no, something went wrong!