0

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

David Faber
  • 12,277
  • 2
  • 29
  • 40

1 Answers1

0

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;
less
  • 699
  • 6
  • 25