--将模板导入SQL Server,导入数据库表的表名为aad
--导入BOM主表资料
insert into bom_bom(Bomid,bomtype,version,versiondesc,versioneffdate,versionenddate,createdate,updcount,vtid,status)
select right(bomid,6),'1','1',版本说明,'2000-01-01 00:00:00.000','2099-12-31 00:00:00.000','2014-06-21 00:00:00.000','0','3042','3' from aad
---导入BOM子件资料
insert into bom_opcomponent( opcomponentid,bomid,sortseq,opseq,componentid,effbegdate,effenddate,fvflag,baseqtyn,baseqtyd,compscrap,byproductflag,optionsid,producttype,recursiveflag)
select idd+462,right(bomid,6),'10','0000','11111','2000-01-01 00:00:00.000','2099-12-31 00:00:00.000','1','1','1','0','0',idd+462,'1','0' from aad
---导入BOM母件资料
INSERT INTO bom_parent(AutoId,BomId, ParentId, ParentScrap, SharingPartId)
select newid(),right(bomid,6),'123','0','0' from aad
--导入子件选项资料
INSERT INTO bom_opcomponentopt(OptionsId, Offset, WIPType, AccuCostFlag, DrawDeptCode, OptionalFlag, MutexRule, PlanFactor)
select idd+462,'0','3','1',领料部门,'0','1','100' from aad
--更新ParentId与bas_part同步
update bom_parent
set bom_parent.ParentId=bas_part.PartId
from bas_part,aad,bom_bom
select * from bom_parent,bas_part,aad,bom_bom
where right(aad.bomid,6)=bom_bom.bomid
and aad.bomid=bas_part.invcode
--更新BOM最大单据号,根据bom_bom,bom_opcomponent,bom_opcomponentopt表实际情况更新iFatherId,ichildid
update UFSystem..ua_identity set iFatherId = XXX,
ichildid=XXX
where cacc_id='帐套号'
and cvouchtype='表名'