100分求SQL将错误数据修改正确
作者: fxsy6669 发布时间: 2011-06-15
作者: anlianganl 发布时间: 2011-06-15
--删除原表数据 truncate table DB1.dbo.tb1 --从备份插入 insert DB1.dbo.tb1 select* from DB2.dbo.tb1
作者: cd731107 发布时间: 2011-06-15
update a set a.x = b.x from DB1..tb1 a, DB2..tb2 b where a.y = b.y
作者: yyoinge 发布时间: 2011-06-15
---在DB1中執行 update t1 set t1.字段=t2.字段 from tb1 t1, DB2.dbo.tb2 t2 Where t1.id=t2.id
作者: X_0 发布时间: 2011-06-15
备注说明:DB1数据库一直在用着,每天都在往库中录入数据,是不能随便删除的。
作者: fxsy6669 发布时间: 2011-06-15
作者: investruth 发布时间: 2011-06-15
from db1.dbo.tb
left join db2.dbo.tb on db1.dbo.tb.id=db2.dbo.tb.id
作者: hsboy86 发布时间: 2011-06-15
SQL code
update a set a.x = b.x
from DB1..tb1 a, DB2..tb2 b
where a.y = b.y
这个可行
作者: jxqn_liu 发布时间: 2011-06-15
cd731107的方法不可行呢。
备注说明:DB1数据库一直在用着,每天都在往库中录入数据,是不能随便删除的。
SQL code
如果表有主键id,这样操作 delete from DB1.dbo.tb1 where id in (select id from DB2.dbo.tb1) --从备份插入 insert DB1.dbo.tb1 select * from DB2.dbo.tb1
作者: cd731107 发布时间: 2011-06-15