2013-03-12 63 views
-1

嗨,我是一個學生在SQL Server 2008中需要幫助試圖讓當前的時間將被添加到表我如何能在當前時間添加到表

我已經研究和是唯一能找到如何顯示當前時間

create table howto 
(
    TimeDifference varchar(20) not null, 
    StartTime DateTime, 
    EndTime DateTime -- this is the current time 
) 
go 

declare @Etime datetime 
select GETDATE() 
set @Etime = getdate() 
go 

回答

2

您可以設置「默認值或綁定」相應列的屬性GETDATE()

alter table howto add constraint EndTimeConstraint default getdate() for EndTime; 

如果你不打算修改將R再次重複,您可以使用製作timestamp類型的列。

+0

哥們謝謝你,你是個傳奇人物 – vash363 2013-03-12 17:48:20