Solved

Identifying FKs with On Delete Cascade from a query.

Posted on 2007-03-27
2
809 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

939 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

Need Help in Real-Time?

Connect with top rated Experts

2 Experts available now in Live!

Get 1:1 Help Now