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 2000 Forums
 Transact-SQL (2000)
 Cascade update and delete

Author  Topic 

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-03-15 : 04:38:47
I have 2 tables tblFileRequets and tblFileRequestDetails which are linked by MovementId. I want to set the relationship to cascade update and delete. However, these tables which originated in Access 97 and are now in SQL, are not in line. ie there are records in tblFileRequests but no corresponding record in tblFileRequestDetails for some of the records. Is there a way I can clear out the records in tblFileRequests so I can set the cascade update and delete ?

TIA

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-03-15 : 04:46:07
you need to resolve this first, delete all records in tblfilerequestdetails that are not in tblfilerequests.

i assume you have some sort of foreign key in the details table that you can use to search through tblfilerequests?

delete from tblfilerequestdetails where key not in (select key from tblfilrequests)

HTH

--------------------
keeping it simple...
Go to Top of Page

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-03-15 : 04:58:04
Thanks jen - perfect.
Go to Top of Page
   

- Advertisement -