请教
 ADOconnection.Execute('Select * Into ['+ScStr+'] from [excel 8.0;database=E:\a].['+ScStr+'$]');
每次执行都说表已经存在,请教我该怎么处理,非常谢谢
能不能有 if exists...的?具体我该怎么写,多谢了

解决方案 »

  1.   

    是不是应该是insert into select * from 啊
      

  2.   

    insert into 往存在的表中插入数据
    select into 用查询语句来创建一个新表
      

  3.   

    ADOconnection.Execute('if not exists(select * from sysobjects where name='''+ScStr+''' and xtype=''U'')'+#13#10+
    'Select * Into ['+ScStr+'] from [excel 8.0;database=E:\a].['+ScStr+'$]');
      

  4.   

    'if not exists(select * from sysobjects where name='''+ScStr+''' and xtype=''U'')'+#13#10+
    'Select * Into ['+ScStr+'] from [excel 8.0;database=E:\a].['+ScStr+'$]'
    楼上的猩猩,这句SQL送过去不会报错吗?
    是不是得加上BEGIN和END:
    'begin +#13#10+ if not exists(select * from sysobjects where name='''+ScStr+''' and xtype=''U'')'+#13#10+
    'Select * Into ['+ScStr+'] from [excel 8.0;database=E:\a].['+ScStr+'$] ; +#13#10+ end;'
      

  5.   

    ADOconnection.Execute('Select * Into ['+ScStr+'] from [excel 8.0;database=E:\a].['+ScStr+'$]');['+ScStr+']是臨時表名稱嗎?如果是,每次執行結束時應該把臨時表DROP掉,或者在執行上句前判斷臨時表是否存在,如果存在就DROP.