1.先在查询分析器里执行

exec sp_configure "show advanced options",1
 reconfigure
 exec sp_configure "Ad Hoc Distributed Queries",1
 reconfigure

2.存储过程

ALTER procedure [dbo].[sp_ImpCustomer]
 @ExcelPath varchar(1000),
 @SheetName varchar(100)='Sheet1',
 @ExcelField varchar(500)='帐号,姓名,机构,经纪人,区域经理,销售行政,电话',
 @TableName varchar(100)='t_busi_callingcust'
as
begin
    set nocount on
    declare @strSql varchar(4000)
    -- 打开开关 
 --exec sp_configure "show advanced options",1
 --reconfigure
 --exec sp_configure "Ad Hoc Distributed Queries",1
 --reconfigure
 -- 重启sql full-text filter daemon launcher,sql server俩个服务
 IF EXISTS  (SELECT * FROM dbo.SysObjects WHERE ID = object_id(@TableName)
  AND OBJECTPROPERTY(ID, 'IsTable') = 1)
  TRUNCATE TABLE t_busi_callingcust -- 删除表中的所有数据
 else
     -- 创建表
  create table t_busi_callingcust(
  Accounts varchar(20) null,
  CustName varchar(50) null,
  Orgazition varchar(50) null,
  [Broker] varchar(50) null,
  DistrictManager varchar(50) null,
  SalesAdmin varchar(50) null,
  Tel varchar(30) null
  )
 SET @ExcelPath = '''Microsoft.Jet.OLEDB.4.0'',''Data Source="' + @ExcelPath + '";User ID=Admin;Password=;Extended properties=Excel 5.0'''
 SET @strSql = 'insert into ' +@TableName+' select * from opendatasource('+@ExcelPath+')...'+@SheetName+'$'
 --print @strsql
 EXEC(@strSql)
 set nocount off
end

最新文章

  1. 深入浅出 Redis client/server交互流程
  2. js事件绑定及深入
  3. JAVA中的枚举小结
  4. [转]编译VC++程序warning C4819快速解决
  5. mysql服务器的字符集
  6. C# 模拟并发
  7. cdoj 1131 男神的礼物 区间dp
  8. tcpdump抓包分析具体解释
  9. 将多个Sheet导入到同一个Excel文件中
  10. AI - 深度学习之美十四章-概念摘要(1~7)
  11. [LeetCode] Number of Matching Subsequences 匹配的子序列的个数
  12. 微信小程序自运营器 微信小程序自动运营器(让你的微信小程序,公众号零运营成本,24小时全自动运营)
  13. 固态硬盘的PCIE,SATA,M2,NVMe,AHCI分别都指什么?别再搞混了
  14. bind注意事项(传引用参数的时候)
  15. ARM架构相关学习归纳总结
  16. 利用Linux的硬连接删除MySQL大文件
  17. jQuery的html和css
  18. 数据库同步相关的SQL语句
  19. AutoCAD 导入 Altium Designer 10 教程
  20. MySQL8 重置改root密码及开放远程访问

热门文章

  1. 我的PHP之旅--认识数据库及数据库操作
  2. oracle 内置函数 least decode
  3. jQuery CSS 添加/删除类名
  4. chr(i) 返回整数i对应的ASCII字符
  5. 转--Server “**” has shut down the connection prematurely一例分析
  6. 如何查看Linux的磁盘空间还有多少
  7. NEERC 2010, Eastern subregional contest
  8. [wikioi]均分纸牌
  9. 定时显示提示控件 TToolTip
  10. Android WebView 开发详解(三)