Relacionar chaves extrageiras

Esse script relaciona as tabelas existentes em um banco de dados com o nome da chave extrangeira e a “tabela pai”

SELECT AS ‘Tabela’ , AS ‘Chave Extrangeira’ , AS ‘Tabela Pai’
FROM sys.foreign_keys A INNER JOIN sys.objects B ON a.parent_object_id = b.object_id
JOIN sys.objects C ON c.object_id = a.referenced_object_id ORDER BY ASC

Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published.