SELECT ForeignTableID = b.fkeyid ,
ForeignTableName = '['+object_name(b.fkeyid) +']' ,
ForeignColumnID = b.fkey ,
ForeignColumnName ='[' +
(SELECT name FROM syscolumns WHERE colid = b.fkey AND id = b.fkeyid) +']',
PrimaryTableID = b.rkeyid ,
PrimaryTableName = '['+object_name(b.rkeyid)+']' ,
PrimaryColumnID = b.rkey ,
PrimaryColumnName ='['+ (SELECT name FROM syscolumns WHERE colid = b.rkey AND id = b.rkeyid) +']' ,
CascadeUpdate = ObjectProperty(a.id,'CnstIsUpdateCascade') ,
CascadeDelete = ObjectProperty(a.id,'CnstIsDeleteCascade')
FROM sysobjects a join sysforeignkeys b on a.id = b.constid
join sysobjects c on a.parent_obj = c.id
where a.xtype = 'f' AND c.xtype = 'U'