我有两个接近相同的表,唯一的区别是较新的有不同的字段名称。基本上,旧桌子已经过时了,需要重新工作;我试图提取所有字段,其中VendorNumber = Vendor_ID所有被复制到的字段保证为空。SQL从旧表中插入新表
下面的SQL代码,如果非常大,但它是我可以用它最好的...
SQL = "INSERT INTO tbleVendorData (EDIContact,EDIPhone,EDIEmail,EDIPlatform,EDIStatus,EDIMigrationStatus,EDIMigrationDate,TesterName,TestStartDate,LastContactDate," & _
"CompletionStatus850,CompletionStatus856,CompletionStatus810C,CompletionStatus810F,CompletionStatusMH10,CompletionStatusPTicket,TestingNotes," & _
"TestingStatus850,TestingStatus855,TestingStatus856,TestingStatus810C,TestingStatus810F,GoLiveDate850,GoLiveDate855,GoLiveDate856," & _
"GoLiveDate810C,GoLiveDate810F,VendorKickOffDate,Exemption,ExemptionStartDate,ExemptionEndDate,ExemptionReason," & _
"ExemptionDescription,Ownership,NECC2500,NECC3500,NECC5000,NECC10000,NECCStartDate,NECCEndDate,SPSCertificate,ProductionStatus850," & _
"ProductionStatus855,ProductionStatus856,ProductionStatus810C,ProductionStatus810F,PlatformFI850,PlatformFI855,PlatformFI856," & _
"PlatformFI810C,PlatformFI810F,ProductionDate850,ProductionDate855,ProductionDate856,ProductionDate810C,ProductionDate810F," & _
"ProductionPrepack,ProductionCrossDock,ProductionMultiStyle,ProductionProductAttribute,ProductionMasterPack,ProductionCrossDockMix," & _
"ProductionStandAloneMix,ProductionLegalEntity,FirstASNDate,FirstINVDate,SALeadDays,CrossDockLeadDays,CommunicationNotes,ProductionNotes," & _
"QU1,QU2,ISA_ID1,ISA_ID2,GS_ID1,GS_ID2,VAN,VAN2,HYBRID) " & _
"SELECT EDI_Contact_Name,EDI_Contact_Phone,EDI_Contact_Email,Platform,Status,Migration_Status,Migration_Date,Tester,Testing_Start_Date,Last_Contact," & _
"Status_850,Status_856,Status_810C,Status_810F,Status_MH10_Label,Status_PTicket,Tnotes,TS_850,TS_855,TS_856,TS_810C,TS_810F,GLD_850,GLD_855," & _
"GLD_856,GLD_810C,GLD_810F,Kick_Off_Mtg,Exemption,Exemption_Start_Date,Exemption_End_Date,Exemption_Text,Exemption_Reason,Ownership," & _
"NECC_2500,NECC_3500,NECC_5000,NECC_10000,NECC_Start_Date,NECC_End_Date,SPS_Certificate,PS_850,PS_855,PS_856,PS_810C,PS_810F,P850_FI,P855_FI," & _
"P856_FI,P810C_FI,P810F_FI,PDTS_850,PDTS_855,PDTS_856,PDTS_810C,PDTS_810F,Prepack,Cross_Dock,[M-style],PCA,Master_Pack,[XD-Mix],[SA-Mix],Legal_Entity," & _
"First_ASN,First_INV,Lead_Days,Cross_Dock_Lead_Days,CNotes,Info,QU1,QU2,ISA_ID1,ISA_ID2,GS_ID1,GS_ID2,VAN,VAN2,HYBRID " & _
"FROM tbleVendorRecord " & _
"WHERE tbleVendorRecord.Vendor_ID = VendorNumber "
我使用的MS Access中VBA并试图运行上面的脚本,我得到的“Enter参数值“供应商编号任何想法,为什么这是?
编辑:
看看你的'WHERE'子句。 –
我做了,它看起来对我来说很好...供应商编号是正确的 – Maldred
看起来对我来说不正确。正如Access暗示给你的,VendorNumber背后的价值是什么?它看起来并不是你的select语句中的一列,或者是一个变量,或者除VendorNumber之外的任何东西。如果引擎不是来自您指定的列,引擎将使用什么值来比较它们? SQL(也不是我)知道答案,所以你会得到一个提示。 –