Re: trigger changing other table
From: Tom Moreau (tom_at_dont.spam.me.cips.ca)
Date: 07/31/04
- Next message: Tom Moreau: "Re: DELETE is slow"
- Previous message: tristant: "Database Design question, Header with two detail.. pls help"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 31 Jul 2004 08:04:18 -0400
Check the value of @@ERROR and if non-zero, issue RAISERROR and ROLLBACK
TRAN.
--
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:ceemkm$okf$1@atlantis.news.tpi.pl...
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
>
>
- Next message: Tom Moreau: "Re: DELETE is slow"
- Previous message: tristant: "Database Design question, Header with two detail.. pls help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|