use MSSQL::TableReferences; my $tr = MSSQL::TableReferences->new($dbh); # $dbh obtained elsewhere # Get information about references FROM this table to other tables $refs = $tr->tablereferences('this_table'); # $refs is now a hashref that describes how this_table # references other_table. $refs = { 'table' => 'this_table', 'alias' => 'tt', 'related' => [ { 'name' => 'other_table', 'alias' => 'ot', 'joins' => [ 'tt.person_id = ot.person_id', 'tt.week_id = ot.week_id' ] } ], }; # Now get information about references TO this table FROM other tables $refs = $tr->tablereferencedby('this_table') # $refs is now a hashref that describes how two # other tables reference this_table. $refs = { 'table' => 'this_table', 'alias' => 'tt', 'related' => [ { 'name' => 'other_table', 'alias' => 'ot', 'joins' => [ 'ot.person_id = tt.person_id' ] }, { 'name' => 'yet_another_table', 'alias' => 'yat', 'joins' => [ 'yat.person_id = tt.person_id', 'yat.week_id = tt.week_id' ] } ] };