Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

How to delete sqltables data with have foreign key and primary key relationship's.

I want to archive the data after to delete relationships. Is there any solution

thanks in advance
Posted

1 solution

First delete the foreign key table data and then the primary key table data
 
Share this answer
 
Comments
K N R 10-Oct-11 7:43am    
Hi sachin,

thanks for your rply.

Suppose if exists foreign key table have a primary key then what's the solution.

can you help me..!
sachin10d 10-Oct-11 8:09am    
deleting data from foreign key table having primary key is possible
what problem are you facing?
K N R 10-Oct-11 8:57am    
suppose i have 3 tables.
create table tabname(tid int primary key,tname varchar(100))
create table tabname1(tid int foreign key references tabname(tid),tabid int primary key)
create table tabname2(tabid int foreign key references tabname1(tabid))
so which table we are going to delete first.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900