日期:2014-05-18  浏览次数:20490 次

这个错误是为何?
存储过程代码如下,我查了又查,Excel表中的确有名为cnm的工作表

SQL code
USE [人保]
GO
/****** Object:  StoredProcedure [dbo].[SJ_JF_JGYL_DW]    Script Date: 02/24/2012 22:07:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        <Author,,Name>
-- Create date: <Create Date,,>
-- Description:    <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[SJ_JF_JGYL_DW]
@FileName char(500)='N:\__SJ_JF_JGYL_DW2005-2011单位应缴实缴明细2.xls'
AS
BEGIN
--sj_zf_xnh
declare @s nvarchar(max)
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here

--truncate table SJ_DB_FFMX

set @s='SELECT XZDM,XZQHDM,TCQDM,DWBH,FKSSQ,DZRQ_DW,ZJFS,JFLX,JFJE_DW_YJ,JFJE_DW_SJ,JFJE_DWHGR,JFJS_DW,JFBL_DW,JFRS_YJ,JFRS_SJ,DZBZ_DW '
set @s=@s+' FROM OpenDataSource( ''Microsoft.Jet.OLEDB.4.0'','
set @s=@s+'''Data Source='+@FileName+';User ID=Admin;Password=;Extended properties=Excel 5.0'') ...[cnm$]'
execute(@s)
set @s='insert __SJ_JF_JGYL_DW '+@s
execute(@s)
END



出错如下:
消息 7314,级别 16,状态 1,第 1 行
链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 不包含表 "cnm$"。该表不存在,或者当前用户没有访问该表的权限。


------解决方案--------------------
你换个名字再试试呢?