批量插入3个文本文件,每个文本文件包含1个lac记录到test1
表中。批量插入到SQL Server 2005中
3个文件中的每一个都有公司代码和作品集。如果test1
表中已经存在compcode和folio,那么我必须使用文本文件中的特定记录更新表,否则将其插入。
但我的查询花了很多时间。 test1
表具有70列
MMY逻辑:
- 在虚设表
- 导入数据比较虚设的每一行与TEST1表
if exists (select * from #dummy , test1 where condition) begin update test1 set col = (#dummy.col).. inner join #dummy on (condition) end
else insert
由于记录是在超过30分钟lacs ..如何我可以证明查询?
过得好比较虚拟表的行与test1表? –
condition =#dummy.companycode +#dummy.folio = test1.companycode + test1.folio –