Solved

Identifying FKs with On Delete Cascade from a query.

Posted on 2007-03-27
2
807 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
Comment Utility
try this:

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

ziolko.
0
 
LVL 18

Author Comment

by:JR2003
Comment Utility
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Suggested Solutions

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…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how the fundamental information of how to create a table.
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…

744 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

15 Experts available now in Live!

Get 1:1 Help Now