Getting all the Foreign Key constraints list of a table in SQL Server

Published on August 26, 2016 by abundantcode

Filed under SQL Server

Last modified August 26, 2016

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 5128 times

You might need to write a T-SQL Query to retrieve all the foreign key constraints of a given table in SQL Server. For these cases , you can use the sp_fkeys stored procedure.

How to get all the Foreign Key constraints list of a table in SQL Server ?

USE AdventureWorks2014;  
GO  
EXEC sp_fkeys @pktable_name = N'Department'  
    ,@pktable_owner = N'HumanResources';  

image

Leave a Comment


x

You might be Interested in these Posts

How to Perform Inner Join using LINQ in C# ?

Are you looking for the syntax on how to perform inner join using LINQ in C# ? . Below is a sample c...

3 New C# 8 Features We Are Excited About

C# is rapidly approaching its third decade of life. Originally released in 2000, the language has gr...

Quick Tip —CSS Containment Module by @gilfink

One of the new hidden gems in the new CSS modules, which is supposed to drop in new browser versions...