当前位置: 代码迷 >> Sql Server >> 显示 消息 102,级别 15,状态 1,第 2 行 '' 附近有语法异常
  详细解决方案

显示 消息 102,级别 15,状态 1,第 2 行 '' 附近有语法异常

热度:864   发布时间:2016-04-24 09:59:50.0
显示 消息 102,级别 15,状态 1,第 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
------解决思路----------------------
SELECT 子句的字段列表不要加括号
------解决思路----------------------
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楼的代码
  相关解决方案