问题
I have a column in an Sql server express table called DepTime which has a Time data type.
I would like to set the Default value for this column to Current Time + 6hrs.
How can I do this.
Thank you
回答1:
here is an example for a temporary table:
CREATE TABLE #tmp (
test varchar(30),
DepTime datetime DEFAULT DATEADD(hour, 6, GETDATE())
);
or if you already have a table:
ALTER TABLE SomeTable
ADD CONSTRAINT DF_SomeTableSomeName
DEFAULT DATEADD(hour, 6, GETDATE()) FOR DepTime;
来源:https://stackoverflow.com/questions/28591389/i-would-like-to-set-the-default-value-for-a-column-to-current-time-6hrs