34,837
社区成员




create table tb(id int, dt datetime default dateadd(year,100,getdate()))
insert into tb(id) values(1)
insert into tb(id) values(2)
insert into tb(id) values(3)
insert into tb(id) values(4)
insert into tb(id) values(5)
go
select * from tb
drop table tb
/*
id dt
----------- ------------------------------------------------------
1 2108-12-30 09:54:39.060
2 2108-12-30 09:54:39.060
3 2108-12-30 09:54:39.060
4 2108-12-30 09:54:39.060
5 2108-12-30 09:54:39.060
(所影响的行数为 5 行)
*/
if object_id('tempdb..#')is not null drop table #
go
create table #([name] varchar(10) primary key)
insert # select 'A'
insert # select 'D'
insert # select 'C'
insert # select 'B'
alter table #
add [date] datetime default dateadd(year,100,getdate())
go
insert #([name]) select 'E'
select * from #
/*name date
---------- ------------------------------------------------------
A NULL
B NULL
C NULL
D NULL
E 2108-12-30 09:51:21.467*/