changed select to use foreign_key_columns system table, this has change in later versions of SQL server