Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trigger Execution
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00799426
Message ID:
00799428
Views:
20
A trigger fires once per command regardless of how many rows are affected. Try
...
	delete from ipdatabase.dbo.physicalAddress
 	  Join deleted on physicalAddress.physical = deleted.physical

>I have a simple trigger that will enforce some referecial integrity in a table in another database. When I delete one record from the trigger table it works, but when the delete statement deletes more than one record I get an error.
>Subquery returned more than 1 value. This is not permitted when the subquery follows 
=, !=, <, <= , >, >= or when the subquery is used as an expression.
>Here is the trigger code.
>
>ALTER  TRIGGER deleteMAC ON astudent FOR DELETE AS
>BEGIN
>
>	delete from ipdatabase.dbo.physicalAddress
> 	where physical = (select nic from deleted)
>
>END
>
>
>Now Im assuming that if I change the '=' to 'IN' it would work. But, I'm not exactly sure how the 'deleted' table is constructed?
>
>Is the delete statement executed, causing all the rows to be deleted, and then the trigger fired with the 'deleted' table containing all those rows that were just deleted. Or does the trigger fire for each row as the rows are being deleted? Like, one row is deleted, the trigger fires with the deleted table containing that one row, then another row is deleted and the trigger fires for that row with the deleted table now containing 2 rows.
>
>I guess now that I think about it the first method seems the most logical. But I just want to make sure.
>
>Eric
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform