Re: Change date with trigger
From: treemusic (treemusic.1balo4_at_mail.mcse.ms)
Date: 08/20/04
- Next message: Hugo Kornelis: "Re: Help Finding records with matching columns"
- Previous message: John Steen: "Help Finding records with matching columns"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 20 Aug 2004 11:45:38 -0500
strellita wrote:
> *I create this trigger, but it change all rows. I change only the
> rows that I insert or update. How can I this?
>
> CREATE TRIGGER [datep] ON [prueba]
> FOR INSERT, UPDATE
> AS
> BEGIN
> UPDATE prueba SET datepm = getdate()
> FROM inserted i
> END *
Needs:
INNER JOIN i.[id column] = preuba.[id column]
after your FROM statement
then it will work correctly.
Full example:
CREATE TRIGGER [datep] ON [prueba]
FOR INSERT, UPDATE
AS
BEGIN
UPDATE p SET datepm = getdate()
FROM inserted i
INNER JOIN preueba p ON i.[ID] = p.[ID]
END
GO
Peace,
tree
-- treemusic ------------------------------------------------------------------------ Posted via http://www.mcse.ms ------------------------------------------------------------------------ View this thread: http://www.mcse.ms/message899238.html
- Next message: Hugo Kornelis: "Re: Help Finding records with matching columns"
- Previous message: John Steen: "Help Finding records with matching columns"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|