Hello i have a SQL Table which look like this:
ID BEZEICHNUNG PREIS UPDATE_DATE FLAG
1 Drake Room 14.06.2012 16:00 0
2 Blazer BS 12.05.2012 14:45 0
when i change a value i want to copy the row with a new id and change the flag to 1
it should look like this:
ID BEZEICHNUNG PREIS UPDATE_DATE FLAG
1 Drake Room 11.07.2012 09:40 1
2 Blazer BS 12.05.2012 14:45 0
3 Dune Room 11.07.2012 09:40 0
when i change the row the update_date updates itself and set a flag to 1.
how can i create an sql statement like this.
the current trigger look like this:
ALTER TRIGGER [dbo].[UPDT_DIENSTLEISTUNG]
ON [dbo].[DIENSTLEISTUNG]
AFTER INSERT, UPDATE
AS
BEGIN
SET NOCOUNT ON;
UPDATE DIENSTLEISTUNG
SET UPDATE_DATE = getdate ()
WHERE id IN (SELECT id
FROM inserted);
END;
Thanks in advance for your help
Please create this trigger first and then try to update the table