Created
February 24, 2017 21:29
-
-
Save asears/38a001e71bf95c322d263c3f47b08c29 to your computer and use it in GitHub Desktop.
Create markdown based on table metadata in SQL Server / SQL DW / Azure SQL
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
select 'header' as tablename,0 as colid, '|id|name|type|length|' as markdown | |
UNION ALL | |
select 'header2' as tablename, 0 as colid, '|---|---|---|---|' as markdown | |
UNION ALL | |
select o.name as tablename, c.colid, convert(varchar(10),c.colid) + '|'+c.name+'|'+ t.name +'|' + convert(varchar(10),c.length) + '|' as markdown | |
from sysobjects o | |
inner join syscolumns c on c.id = o.id | |
inner join systypes t on t.xtype = c.xtype | |
where o.name = 'mytable' | |
order by tablename, colid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment