sqlserver 两个数据库中表的结构不同,怎么把一个表中的数据导入到另一个表中
vb做的数据导入导出工具 把一个数据库中某些表中的数据导入到另一个数据库中的表中,表结构有不相同的表的字段有相同的...
vb 做的数据导入导出工具 把一个数据库中某些表中的数据导入到另一个数据库中的表中,表结构有不相同的表的字段有相同的
展开
3个回答
展开全部
我可以给你个我自己的例子,具体的你照着这个例子去修改吧,可能对你有帮助
insert into DAY(numchnid,numsrvid,numprovid,numgwid,r_day,mo_all,mt_all,mt_valid,mt_userr,mt_sum)
select v.numchnid, v.numsrvid, v.numprovid, v.numgwid, DATE(v.r_day), v.mo_all,
case when w.mt_all is null then 0 else w.mt_all end,
case when w.mt_valid is null then 0 else w.mt_valid end,
case when w.mt_user is null then 0 else w.mt_user end,
case when w.sumfee is null then 0 else w.sumfee end
from report_tmp3 v
left join report_tmp4 w
on v.numchnid = w.numchnid
and v.numsrvid = w.numsrvid
and v.numprovid = w.numprovid
and v.numgwid = w.numgwid
and v.r_day = w.r_day;
commit;
insert into DAY(numchnid,numsrvid,numprovid,numgwid,r_day,mo_all,mt_all,mt_valid,mt_userr,mt_sum)
select v.numchnid, v.numsrvid, v.numprovid, v.numgwid, DATE(v.r_day), v.mo_all,
case when w.mt_all is null then 0 else w.mt_all end,
case when w.mt_valid is null then 0 else w.mt_valid end,
case when w.mt_user is null then 0 else w.mt_user end,
case when w.sumfee is null then 0 else w.sumfee end
from report_tmp3 v
left join report_tmp4 w
on v.numchnid = w.numchnid
and v.numsrvid = w.numsrvid
and v.numprovid = w.numprovid
and v.numgwid = w.numgwid
and v.r_day = w.r_day;
commit;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询