At times as a DBA/DB Programmer we may need to generate a report on foreign keys across all the tables in a given database. It would be a tedious job to use the SQL Server Management studio and build a relationship diagram. Here is a tip to quickly query the meta data and depict all the foreign keys.
select * from (
object_name(constid) as 'ConstraintName',
object_name(fkeyid) as 'Detail' ,
c.name as 'Detail.Column'
) as Detail,
object_name(rkeyid) as 'Master' ,
c.name as 'Master.Column'
where f.rkey=c.column_id and
where Detail.constid = Master.constid