Created
June 12, 2013 21:05
-
-
Save anonymous/5769102 to your computer and use it in GitHub Desktop.
Using OPENROWSET to import Excel files into SQL Server 2008 using the Access Engine [http://www.microsoft.com/en-us/download/details.aspx?id=13255]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
First, you must configure ad hoc distributed queries, and configure the Access engineto work in SQL Server | |
*/ | |
sp_configure 'show advanced options', 1; | |
GO | |
RECONFIGURE; | |
GO | |
sp_configure 'Ad Hoc Distributed Queries', 1; | |
GO | |
RECONFIGURE; | |
GO | |
exec sp_configure 'Advanced', 1; | |
GO | |
RECONFIGURE; | |
GO | |
exec sp_configure 'Ad Hoc Distributed Queries', 1; | |
GO | |
RECONFIGURE; | |
GO | |
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1 | |
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1 | |
RECONFIGURE; | |
GO | |
SELECT * | |
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;HDR=Yes;Database=C:\the\path\to\myfile.xlsx;', 'SELECT * FROM [Sheet1$]') -- also works with spaces |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment