You can use the OBJECTPROPERTY()
function in SQL Server to find out whether or not an object is a foreign key.
To find out whether an object is a foreign key, pass the object ID as the first argument, and IsForeignKey
as the second argument. The function returns a 1
or a 0
depending on whether or not it’s a foreign key.
A return value of 1
means that it is a foreign key, and a value of 0
means that it isn’t.