First of all:
You cannot connect a 32-bit office to a 64-bit SQL. Period.
You need:
64-bit OS
Windows Server 2008 64-bit
Office 2010 64-bit
2010 64-bit OLEDB Drivers
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c06b8369-60dd-4b64-a44b-84b371ede16d
Go to SQL Management Studio,
Log in as SA
run this
------------------------------------------------------------
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
USE [master]
GO
EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1
GO
EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1
GO
(Original Post)
------------------------------------------------------------
Save your excel file as C:\db\myfile.xlsx
Run this
-------------------------------------------------------------
SELECT * FROM OPENROWSET ( 'Microsoft.ACE.OLEDB.12.0',
'Excel 12.0; Database=C:\db\myfile.xlsx;HDR=Yes', 'Select * from [sheet1$]' )
or
'Excel 12.0; Database=C:\db\myfile.xlsx;HDR=Yes', 'Select * from [sheet1 - table 1$]' )
--------------------------------------------------------------
For 32-Bit Excel, and SQL use
--------------------------------------------------------------
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;HDR=YES;Database=C:\temp\test.xls',
'select * from [sheet1$]')
Database: Path and name of your excel file
HDR: Yes/No if to include headers or not
Sheet1$: Replace with the sheet name you want to access in your excel file (leave the $ on the end)
You should be able to access your excel file.
No comments:
Post a Comment