Re: insert trigger help

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: soc (zxc0_at_yahoo.com)
Date: 06/10/04


Date: Thu, 10 Jun 2004 15:01:33 +0100

Thanks David,
yes a join is better
Soc
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:fqOdnebwrJhN11XdRVn-vg@giganews.com...
> 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
> --
>
>



Relevant Pages

  • Re: insert trigger help
    ... come to query them. ... CREATE TRIGGER trgContacts ON Contacts FOR INSERT ... SET accountno = ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Trigger question
    ... Why do you want to do this with a trigger? ... Calculate that column when you query the data instead: ... ELSE explanation END AS explanation ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: getting data in triggers
    ... transaction will hold everything in lock until your trigger is done. ... Looking at your vbscript, you are making a new sqlconnection and attempting ... suggest you create a sql job and schedule it to run these external calls at ... >>> I can execute the script using xp_CmdShell in the SQL Query Analyzer ...
    (microsoft.public.sqlserver.programming)
  • Re: Please help me optimise this stored procedure.
    ... But do you really need this query? ... I assume your query is run in a trigger. ... UPDATE Titles ... Also, I forgot that the counters are in another table, not ...
    (microsoft.public.sqlserver.programming)
  • Re: Use INSERTED and DELETED in SP
    ... > an "universal History Trigger". ... inserted or deleted data) into one HISTORY table. ... > should be a somehow transaction log, ... >>SQL Server MVP ...
    (microsoft.public.sqlserver.programming)