Solved

Identifying FKs with On Delete Cascade from a query.

Posted on 2007-03-27
2
816 Views
Last Modified: 2008-03-03
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.

0
Comment
Question by:JR2003
2 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 500 total points
ID: 18798735
try this:

sp_MStablerefs N'dbo.Table1', N'actualtables', N'both', null

ziolko.
0
 
LVL 18

Author Comment

by:JR2003
ID: 18798790
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question