[VB]
static void OutputDbTableRelationships()
{
SQLServerClass sqlServer = new SQLServerClass();
sqlServer.LoginSecure = true;
sqlServer.Connect("localhost", null, null);
_Database db = sqlServer.Databases.Item("Northwind", null);
foreach(_Table table in db.Tables)
{
foreach(Key key in table.Keys)
{
if(key.Type != SQLDMO_KEY_TYPE.SQLDMOKey_Foreign)
continue;
Console.WriteLine("{0}.{1} references {2}.{3}", table.Name, key.KeyColumns.Item(1), key.ReferencedTable, key.ReferencedColumns.Item(1));
}
}
}
[/VB]