如题如何用CREATE TABLE 建表时设置一个GETDATE()时间列以后每次登录数据时都不用输入当前时间如
T1表中 a , b , c 三列每次只需要输入a ,b 列的值就可以,C 列自动被赋值为GETDATE()建表时能实现吗?我用
default getdate()建表之后 不好用如下
CREATE TABLE [MstProcRegTime] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[RegisterTime] [datetime] NOT NULL ,
[BatRunTime] [datetime] NULL DEFAULT (getdate())
) ON [PRIMARY]
GOinsert into MstProcRegTime select '2008/10/05'这样插不进去insert into MstProcRegTime select '2008/10/05','2008/10/05'这样就可以给点解决办法吧谢谢大家
T1表中 a , b , c 三列每次只需要输入a ,b 列的值就可以,C 列自动被赋值为GETDATE()建表时能实现吗?我用
default getdate()建表之后 不好用如下
CREATE TABLE [MstProcRegTime] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[RegisterTime] [datetime] NOT NULL ,
[BatRunTime] [datetime] NULL DEFAULT (getdate())
) ON [PRIMARY]
GOinsert into MstProcRegTime select '2008/10/05'这样插不进去insert into MstProcRegTime select '2008/10/05','2008/10/05'这样就可以给点解决办法吧谢谢大家
insert into @tb(id) select 1
insert into @tb(id) select 2
insert into @tb(id) select 3select * from @tbid dt
1 2008-03-10 10:00:59.107
2 2008-03-10 10:00:59.107
3 2008-03-10 10:00:59.107
---------------
没指定要插入的时间列:
insert into MstProcRegTime(RegisterTime) select '2008/10/05'