Skip to main content

Posts

Showing posts from 2025

Import Data from Excel sheet in SQL Server

https://www.microsoft.com/en-us/download/details.aspx?id=54920 SELECT * FROM OPENROWSET( 'Microsoft.ACE.OLEDB.12.0', 'Excel 8.0;HDR=NO;Database=D:\temp\Test.xlsx', 'select * from [sheet1$]') Before doing that, make sure you are a local admin in SQL Server and execute the following EXEC sp_configure 'show advanced options', 1 RECONFIGURE GO EXEC sp_configure 'ad hoc distributed queries', 1 RECONFIGURE GO Sometimes you may receive Microsoft OLEDB error, 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 EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DisallowAdHocAccess', 0 GO To Get list of all sheets in a workbook, use the following declare @FileName varchar(max) = 'test-file' declare @...