Skip to content

Instantly share code, notes, and snippets.

View FranzM91's full-sized avatar

Franz Mamani FranzM91

  • Qhanati
  • Cochabamba
View GitHub Profile
@FranzM91
FranzM91 / showRelationships.sql
Created September 9, 2022 13:09 — forked from gourab5139014/showRelationships.sql
SQL Server Script to show all FK relationships in the current database
SELECT
fk.name 'FK Name',
tp.name 'Parent table',
cp.name, cp.column_id,
tr.name 'Refrenced table',
cr.name, cr.column_id
FROM
sys.foreign_keys fk
INNER JOIN
sys.tables tp ON fk.parent_object_id = tp.object_id