I just want an update trigger like this postgresql version… It seems to me there is no NEW. and OLD. in MSSQL?
CREATE OR REPLACE FUNCTION "public"."ts_create" () RETURNS trigger AS
DECLARE
BEGIN
NEW.ctime := now();
RETURN NEW;
END;
Googled already, but nothing to be found unfortunately… Ideas?
Update:
Sth, like this?
CREATE TRIGGER tr01 ON Auctions for insert
As
update auctions set mtime = GETDATE() where Id = inserted.Id;
or this:
CREATE TRIGGER tr01 ON Auctions for insert
As
inserted.ctime := GETDATE();
bothg dont work of course 😉
In SQL Server the pseudo tables are called INSERTED and UPDATED.
I would use a default constraint on the ctime column for your particular example, however:
or
A trigger fires once for an entire INSERT statement, so, in general, the INSERT AND DELETED tables may contain multiple rows.