Re: insert trigger help
From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 06/10/04
- Next message: Uri Dimant: "Re: SQL Query Help"
- Previous message: Karl Rhodes: "Help with recursive query for Hierarchal information"
- In reply to: soc: "insert trigger help"
- Next in thread: soc: "Re: insert trigger help"
- Reply: soc: "Re: insert trigger help"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Jun 2004 12:48:52 +0100
Are you sure you need a trigger? You could just join the two tables when you
come to query them (create a view to do this if you like). That way you
don't have to keep updating anything.
CREATE TRIGGER trgContacts ON Contacts FOR INSERT
AS
UPDATE Clients
SET accountno =
(SELECT DISTINCT accountno
FROM Inserted
WHERE email = Clients.email)
WHERE EXISTS
(SELECT *
FROM Inserted
WHERE email = Clients.email)
I'm assuming that it's only possible to insert 1 account number per email
address.
-- David Portas SQL Server MVP --
- Next message: Uri Dimant: "Re: SQL Query Help"
- Previous message: Karl Rhodes: "Help with recursive query for Hierarchal information"
- In reply to: soc: "insert trigger help"
- Next in thread: soc: "Re: insert trigger help"
- Reply: soc: "Re: insert trigger help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|