Reputation: 3285
I have table which is filled from external application. I need to fill column datetime with current datetime. This column is not filled by insert query provided by external application. Is there some option? Maybe some trigger?
Upvotes: 2
Views: 7592
Reputation: 107247
You can default your timestamp as follows
CREATE TABLE X
(
...
[TimeStamp] DATETIME DEFAULT(CURRENT_TIMESTAMP)
)
Upvotes: 0
Reputation: 65157
ALTER TABLE MyTable
ADD CONSTRAINT [DT_Default]
DEFAULT (GETDATE()) FOR [MyDatetimeField]
GO
Upvotes: 4
Reputation: 7761
You can set the Default Value or Binding
for your date column in SQL Server Mgmt Studio to a function like GETUTCDATE()
Upvotes: 4