Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 FOREIGN KEY constraint

Author  Topic 

desikankannan
Posting Yak Master

152 Posts

Posted - 2012-06-14 : 05:44:07
how to find existing foreign key relation ship by query?

Desikankannan

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-06-14 : 05:50:40
sys.sp_MSdependencies


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

desikankannan
Posting Yak Master

152 Posts

Posted - 2012-06-14 : 06:07:53
after deleting all child tables still im getting this error
"Cannot truncate table 'PWS_Interviewee' because it is being referenced by a FOREIGN KEY constraint."

quote:
Originally posted by desikankannan

how to find existing foreign key relation ship by query?

Desikankannan





Desikankannan
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2012-06-14 : 07:02:48
You need to drop the foreign keys in the table PWS_Interviewee.

After Monday and Tuesday even the calendar says W T F ....
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2012-06-14 : 12:21:54
[code]-- Find Foreign Keys that reference PWS_Interviewee
select
FK_Name = object_name(object_id),
FK_Referencing_Table = object_name(parent_object_id),
FK_Table_Referenced = object_name(referenced_object_id),
*
from
sys.foreign_keys
where
referenced_object_id = object_id('PWS_Interviewee','U')[/code]




CODO ERGO SUM
Go to Top of Page
   

- Advertisement -