Re: trigger changing other table

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Artur Z. (artekzx_at_o2.pl)
Date: 07/30/04


Date: Sat, 31 Jul 2004 01:46:48 +0200

thanks Tom and Ian, it worked

I have one more question:
how to throw an exception from trigger ?
for example when I decide in trigger that his delete operation should be
rolled back

thanks again

Artur

Uzytkownik "Tom Moreau" <tom@dont.spam.me.cips.ca> napisal w wiadomosci
news:#ZFbyMmdEHA.2384@TK2MSFTNGP09.phx.gbl...
> Yes, you can:
>
> CREATE TRIGGER trigger1 ON customer FOR DELETE AS
> UPDATE note
> SET
> status = 2
> WHERE
> customer_id in
> (
> select
> id
> from
> deleted
> )
>
>
>
> --
> Tom
>
> ---------------------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinnaclepublishing.com/sql
>
>
> "Artur Z." <artekzx@o2.pl> wrote in message
> news:cee414$fhc$1@nemesis.news.tpi.pl...
> hello
>
> I'm here for the first time so hello everybody :)
>
> I came here to ask one question, because I have a problem with mssql
trigger
> creation:
> is it possible to create trigger on table A which modifies some records in
> table B ?
>
> I got the following error:
> "The column prefix 'deleted' does not match with a table name or alias
name
> used in query."
> when I try to create trigger:
> CREATE TRIGGER trigger1 ON customer FOR DELETE AS
> UPDATE note SET note.status = 2 WHERE note.customer_id = deleted.id
>
> is there any solution of this problem ?
>
> thanks in advance
>
> Artur
>
>



Relevant Pages

  • Re: trigger changing other table
    ... Columnist, SQL Server Professional ... for example when I decide in trigger that his delete operation should be ... > SQL Server MVP ... > "Artur Z." ...
    (microsoft.public.sqlserver.programming)
  • Re: Logging database changes
    ... I use a "changes" file with a nask key and fields containing record- ... I have a generic trigger subroutine that I clone & modify for each new ... as those equate lists must be managed ... frequently, like customer balance, etc. ...
    (comp.databases.pick)
  • Re: Handle Triggers in MS Access 2003 with SQL Server as Back-End
    ... I have a trigger created for Customer table. ... Check if there is already a record in the NewCustTracker ... DECLARE @userName nvarchar; ...
    (comp.databases.ms-access)
  • Re: Logging deletes...
    ... when the customer record is deleted, the trigger is fired and then the row ... is added to the delcustomer table it would automatically add the datetime ... Here is my current trigger: ... > Columnist, SQL Server Professional ...
    (microsoft.public.sqlserver.programming)
  • Re: How to generate a merge conflict in a trigger ?
    ... The error that I raise in the trigger happends when I insert a record in the ... Subscriber with a "customer friendly identification" and before it ... CFI, having both rows actives. ...
    (microsoft.public.sqlserver.replication)