解决方案 »

  1.   

    SELECT 子句的字段列表不要加括号
      

  2.   

    use ProjectApplication
    EXEC sp_configure 'show advanced options',1;
    GO
    RECONFIGURE
    GO
    EXEC sp_configure 'Ad Hoc Distributed Queries',1
    GO
    RECONFIGURE
    GO
    insert into ItemStatistics(Xh,ItemNo,StarDate,Fund,ItemName,OnUnit,ManageUnit,PlanCate,SubCate,ManageDepartment,ItemPI,EndDate,Status,AcceptNo,AuthenticateNo)      
    select Xh,ItemNo,StarDate,Fund,ItemName,OnUnit,ManageUnit,PlanCate,SubCate,ManageDepartment,ItemPI,EndDate,Status,AcceptNo,AuthenticateNo from
    OpenDataSource('Microsoft.Ace.OLEDB.12.0','Data Source="C:\pmdata\importtable0918.xlsx";Extended properties="Excel 12.0;HDR=Yes"')...[sheet2$]
    go 
      

  3.   

    完全重复的可以用distinct,但是如果部分重复的话就要根据业务来处理了
      

  4.   

    完全重复,在在select后直接加distinct就行了吗?
      

  5.   

    use ProjectApplication
    EXEC sp_configure 'show advanced options',1;
    GO
    RECONFIGURE
    GO
    EXEC sp_configure 'Ad Hoc Distributed Queries',1
    GO
    RECONFIGURE
    GO
    insert into ItemStatistics(Xh,ItemNo,StarDate,Fund,ItemName,OnUnit,ManageUnit,PlanCate,SubCate,ManageDepartment,ItemPI,EndDate,Status,AcceptNo,AuthenticateNo)      
    select distinct Xh,ItemNo,StarDate,Fund,ItemName,OnUnit,ManageUnit,PlanCate,SubCate,ManageDepartment,ItemPI,EndDate,Status,AcceptNo,AuthenticateNo from
    OpenDataSource('Microsoft.Ace.OLEDB.12.0','Data Source="C:\pmdata\importtable0918.xlsx";Extended properties="Excel 12.0;HDR=Yes"')...[sheet2$]
    go 
    借用2楼的代码