List foreign keys for a specified table

I'm trying to list all of the foreign key relationships for a specified table.

I was thinking I could use
sp_fkeys 'enrollments' but this is not returning the desired results.
LVL 8
JRockFLAsked:
Who is Participating?
 
BrandonGalderisiConnect With a Mentor Commented:
SQL 2000

select ro.name from sysobjects o
join sysobjects ro
on o.id=ro.parent_obj
join sysreferences r
on r.constid=ro.id
where o.id= object_id('YOURTABLENAME')
0
 
OBonioCommented:
Which version of SQL Server?  With 2005 you can use the Sys.foreign_keys table to link to Sys.objects, though I think you may need Sys.columns also as foreign keys apply to columns rather than tables....

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.