Re: Logging deletes...
From: Chris Marsh (cmarsh_at_synergy-intl.com)
Date: 11/12/04
- Next message: Aaron [SQL Server MVP]: "Re: Loop all files..?"
- Previous message: David Gugick: "Re: Indexes - System tables"
- In reply to: Hugo Kornelis: "Re: Logging deletes..."
- Next in thread: Hugo Kornelis: "Re: Logging deletes..."
- Reply: Hugo Kornelis: "Re: Logging deletes..."
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 12 Nov 2004 18:51:42 -0500
Hugo, what am I missing? This doesn't appear to be working and here is what
I get once I add the getdate() value to the select line:
Error 121: The select list of the INSERT statement contains more items than
the insert list. The number of SELECT values must match the number of
INSERT columns.
Thanks,
Chris
"Hugo Kornelis" <hugo@pe_NO_rFact.in_SPAM_fo> wrote in message
news:37gap0dqsd4et5bss3c8fjguu86ltqdgs3@4ax.com...
> On Fri, 12 Nov 2004 12:43:18 -0500, Chris Marsh wrote:
>
>>I am confident that if I get one of those values to update then I can add
>>the addtional values as well. Here is my current trigger:
>
> Hi Chris,
>
> You need a small change to the syntax:
>
> CREATE TRIGGER [SaveDeletedCustomer] ON [dbo].[customer]
> INSTEAD OF DELETE -- Must use INSTEAD OF as the customer table has many
> Text columns.
> AS
>
> INSERT INTO delcustomer (cusid, ..., del_datetime, del_user, del_host)
> SELECT cusid, ..., getdate(), suser_sname(), host_name()
> FROM deleted
>
> DELETE customer
> FROM deleted
> WHERE customer.cusid = deleted.cusid
>
> (untested)
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Aaron [SQL Server MVP]: "Re: Loop all files..?"
- Previous message: David Gugick: "Re: Indexes - System tables"
- In reply to: Hugo Kornelis: "Re: Logging deletes..."
- Next in thread: Hugo Kornelis: "Re: Logging deletes..."
- Reply: Hugo Kornelis: "Re: Logging deletes..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|