bluesand4
asked on
get date of record insertion
Hi,
I have sql server 2005. Clients will connect to a db on this server and insert some records. I want to have a column that will be filled with the date of record insertion.
I don't want to get the client's date (since he may change the date/time on his system), i want to get the server's date and time.
Regards
I have sql server 2005. Clients will connect to a db on this server and insert some records. I want to have a column that will be filled with the date of record insertion.
I don't want to get the client's date (since he may change the date/time on his system), i want to get the server's date and time.
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
I have the following trigger:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER dbo.hi
ON dbo.tblContract
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
update dbo.tblContract set inserted = getdate()
END
GO
the column is called inserted
but i have now a problem: this called will be updated with the current time for all records..... I want to affect only the record having been now created
I have the following trigger:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER dbo.hi
ON dbo.tblContract
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
update dbo.tblContract set inserted = getdate()
END
GO
the column is called inserted
but i have now a problem: this called will be updated with the current time for all records..... I want to affect only the record having been now created
alter table Yourtable add CreationTime datetime not null default getdate()