Skip to content

Instantly share code, notes, and snippets.

@skalinets
Created May 17, 2017 16:14
Show Gist options
  • Save skalinets/1e592f45752b02b931f865d24b5bc002 to your computer and use it in GitHub Desktop.
Save skalinets/1e592f45752b02b931f865d24b5bc002 to your computer and use it in GitHub Desktop.
void Main()
{
var matches = this.ExecuteQuery<SysObject>(@"SELECT Table_Schema, TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH,
NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE,
DATETIME_PRECISION
FROM INFORMATION_SCHEMA.COLUMNS");
var content = matches.GroupBy(_ => _.Table_Name)
.Aggregate(new StringBuilder(), (sb, g)
=> g.Aggregate(sb
.AppendLine($"# {g.Key}")
.AppendLine("| *Column Name* | *Data Type* | *Description* ")
.AppendLine("|--|--|--"),
(ssb, i) => ssb.AppendLine($"| {i.Column_Name} | {i.Data_Type} | {i.Column_Name} |")))
.ToString();
var filename = System.IO.Path.GetTempPath() + "tables.markdown";
System.IO.File.WriteAllText(filename, content);
System.Diagnostics.Process.Start("code", filename);
}
class SysObject
{
public string Table_Schema;
public string Table_Name;
public string Column_Name;
public string Data_Type;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment