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.

55<br />

Chapter 2: Documenting your Database<br />

THEN 'lineheader'<br />

WHEN @PreviousState NOT IN ( 'lineheader',<br />

'header' )<br />

AND TheChar = ''''<br />

THEN CASE WHEN @PreviousState = 'string'<br />

THEN 'possibleEnd'<br />

WHEN @PreviousState = 'possibleend'<br />

THEN 'string'<br />

WHEN @PreviousState 'string'<br />

THEN 'string'<br />

ELSE 'string'<br />

END<br />

WHEN @PreviousState = 'possibleend'<br />

THEN 'code'<br />

ELSE @PreviousState<br />

END ,<br />

@output = output = CASE WHEN @state = 'lineheader'<br />

AND TheChar IN ( CHAR(13), CHAR(10) )<br />

THEN ''<br />

WHEN @PreviousState @state<br />

AND @state = 'lineheader'<br />

THEN CHAR(13) + CHAR(10) + TheChar<br />

ELSE TheChar<br />

END<br />

--now assemble the header<br />

SELECT @Header = ''<br />

SELECT @Header = @Header + [Output]<br />

FROM @parser<br />

WHERE state IN ( 'header', 'lineheader' )<br />

ORDER BY theorder<br />

GO<br />

Listing 2-11: Extracting documentation from routines.<br />

We can now use this procedure to provide the headers for all the routines in the<br />

database. The YAML output can then be converted into an XML fragment, then<br />

translated into any required format with XSLT. The YAML can be consumed by Ruby<br />

or Python and converted into native object formats.

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

Saved successfully!

Ooh no, something went wrong!