SQL Server 导入EXCEL数据

一、导入本地的excel数据到本地数据库,流程如下:

1、--启动OpenDataSource

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

2、--查询excel的数据

SELECT * FROM OpenDataSource
( 'Microsoft.ACE.OLEDB.12.0','Data Source="C:\Users\Think\Desktop\粗细联格式.xlsx";Extended properties=Excel 12.0')...[Sheet1$]

3、--将excel表数据插入数据库表中

INSERT  INTO 粗细联.接口参数属性
        ( 接口参数名 ,
          参数属性
        )
        SELECT  接口参数名 ,
                        参数属性
        FROM    OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0',
                               'Data Source="C:\Users\Think\Desktop\粗细联格式.xlsx";Extended properties=Excel 12.0')...[Sheet1$];

过程中可能会遇到的问题:尚未注册 OLE DB 访问接口 "Microsoft.ACE.OLEDB.12.0"

有的语句里是Micr

你可能感兴趣的:(SQL Server 导入EXCEL数据)