alter table table1 add tid int identity(1,1)
go
alter table table2 add tid int identity(1,1)
go
update  a set a.time1=b.time1 from table1 a join table2 b on a.tid=b.tid
go
alter table table1 drop column tid
alter table table2 drop column tid
go
只会这样做

解决方案 »

  1.   

    alter table table1 add tid int identity(1,1)
    go
    alter table table2 add tid int identity(1,1)
    go
    update  a set a.time1=b.time1 from table1 a join table2 b on a.tid=b.tid
    go
    alter table table1 drop column tid
    alter table table2 drop column tid
    go
    已经可以了!
      

  2.   

    這還不是我想要的啊,不過得感謝樓上的幾位!!!
    現在我的表一中有五千條記錄(但time1值為空),表二中有一萬條記錄,我現在想把表一中的一部分符合一定條件的記錄的time1值用表二中符合一定條件的記錄的time1值來更新。這如何做到啊?
      

  3.   

    我的條件就是把表一中的符合條件的記錄用表二中符合條件的記錄來進行更新,
    比如:表一中符合下列條件的記錄要進行更新:time1 BETWEEN '2001-11-01 08:20:30.500'
    AND '2003-02-11 17:30:10.500',但要求使用表二中符合下列條件的記錄來更新它:Convert(varchar(12),time1,121) <> '08:00:00.000' AND Convert(varchar(12),time1,121)<> '17:00:00.000'.