use varis_p
go

declare 
@table varchar(50) = 'dbo.SomeTable'

select md from (
	-- Row 1 - Headers
	select 
		-2 as colid,
		'| Name | Type | Nullable | Other Properties | Notes |' as md
	union all

	-- Row 2 - Underline
	select 
		-1 as colid, 
		'|-|-|-|-|-|' as md
	union all

	-- Data rows
	select
		c.colid,
		'| '+ c.name 
		+' | ' + t.name 
		+ case when t.name in ('varchar', 'char', 'nvarchar', 'nchar') then '('+ cast(c.length as varchar(50)) +')' else '' end
		+' | ' + case when isnullable = 1 then 'yes' else 'no' end 
		+' |' as md
	from sysobjects as o
		join syscolumns as c on o.id=c.id
		join systypes as t on t.xtype=c.xtype
	where o.id=object_id(@table)
) as x
order by colid