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
 SQL Server Development (2000)
 delete help

Author  Topic 

mariechristine
Starting Member

27 Posts

Posted - 2004-08-05 : 04:33:55

i have table Controller (ControllerID, ControllerNAme, isActive)
and tables SendControllerForCitizenClaim (SendID, ControllerID, Region),
table SendControllerForCompanyClaim (SendID, ControllerID, REgion)..
and so on .. i have 14 tables of SendController each for a certain purpose.

I have a procedure for deleting controllers. I want that if a controller is sent (i.e its id is in at least one of the tables) then isActive=0 otherwise if the controller id isn't present in neither of the 14 tables then delete controler record.

How do i do that wihout having to write 14 If Not exists statements??

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-08-05 : 05:04:27
i'm not sure if this will work, but it doesn't hurt to try.

if exists select ControllerID from t1 left join t2 on (t1.ControllerID = t2.ControllerID)
left join t3 on (t2.ControllerID = t3.ControllerID)...
left join t14 on (t13.ControllerID = t14.ControllerID)
where t1.ControllerID = 5 or t2.ControllerID = 5 or ... or t14.ControllerID = 5

Go with the flow & have fun! Else fight the flow :)
Go to Top of Page
   

- Advertisement -