How can I get all the constraints from the DB where one field is referenced to another field in the same table?
This type of reference can strongly affect performance, so I want to find all these references in my DB and analyze them.
Example of the table structure:
CREATE TABLE MyTable(id uniqueidentifier NOT NULL PRIMARY KEY, ReferentID uniqueidentifier)
ALTER TABLE [dbo].MyTable WITH CHECK ADD CONSTRAINT [TEST_FK] FOREIGN KEY([ReferentID])
REFERENCES [dbo].MyTable ([Id])
GO
ALTER TABLE [dbo].MyTable CHECK CONSTRAINT [TEST_FK]
GO