Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: How to DELETE from two connected tables?


Message #1 by "Jon Maz" <jpokroy@m...> on Sun, 11 Nov 2001 23:32:14
Thanks to David and Sammy for your suggestions.

I have found out what was going on - the trigger below (t_topics_Delete) 
was somehow interfering.  I deleted the trigger, and the DELETE statement 
worked, with no weird error message!

Now I have to figure out what the trigger was doing (I didn't write it), 
and see what functionality has been lost by removing it and now has to be 
replaced in some other way (that doesn't screw up the DELETE!)

Thanks again,

JON



Create Trigger t_topics_Delete
On dbo.t_topics
For Delete
As
	Declare @topic_id int
	select @topic_id = (select topic_parent from deleted)
	if @topic_id=-1 
		begin
			DELETE a FROM t_topics a , deleted b WHERE 
(a.topic_parent = b.topic_id)		
		end
	else
		update a set a.topic_count = a.topic_count -1 from 
t_topics a, deleted b where a.topic_id = b.topic_parent

  Return to Index