Created
July 2, 2012 21:35
-
-
Save colinangusmackay/3035858 to your computer and use it in GitHub Desktop.
A T-SQL script that renders media wiki markup of a list of tables or views that can be used in the creation of a data dictionary. More details on my blog: http://colinmackay.co.uk/2012/06/14/creating-a-data-dictionary-with-sql-server-and-mediawiki-part-on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- For more information about this script and its uses, visit: | |
-- http://colinmackay.co.uk/2012/06/14/creating-a-data-dictionary-with-sql-server-and-mediawiki-part-one-a-list-of-tables/ | |
DECLARE @Type NVARCHAR(100) = 'BASE TABLE' -- 'VIEW' OR 'BASE TABLE' | |
DECLARE @catalogue SYSNAME; | |
DECLARE @schema SYSNAME; | |
DECLARE @name SYSNAME; | |
SET NOCOUNT ON | |
PRINT '{| class="wikitable sortable" | |
|- | |
! scope="col" | Schema | |
! scope="col" | Table | |
! scope="col" class="unsortable" | Notes | |
' | |
DECLARE table_cursor CURSOR FOR | |
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE TABLE_TYPE=@Type | |
ORDER BY TABLE_SCHEMA, TABLE_NAME; | |
OPEN table_cursor | |
FETCH NEXT FROM table_cursor | |
INTO @catalogue, @schema, @name | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
PRINT '|- | |
| '+ @schema+' | |
| [[' + @catalogue + '.'+@schema+'.'+@name + '|'+ @name+']] | |
| | |
' | |
FETCH NEXT FROM table_cursor | |
INTO @catalogue, @schema, @name | |
END | |
PRINT '|}' | |
CLOSE table_cursor; | |
DEALLOCATE table_cursor; | |
SET NOCOUNT OFF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment