Link to home
Start Free TrialLog in
Avatar of JR2003
JR2003

asked on

Identifying FKs with On Delete Cascade from a query.

I would like to identify whether a foreign key has the delete cascade option set by querying SQL Server system tables.
I need a query which shows the FKs on a database and whenther the delete cascade option set.

ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JR2003
JR2003

ASKER

Thanks that works. I also found the ObjectProperties function gives the result I want.

select so.name,
       objectproperty(so.id, 'CnstIsDeleteCascade') AS DeleteCascade
  from sysforeignkeys fk
 inner join sysobjects so
         on fk.constid = so.id