You can make a select
fine directly in your spreadsheet:
(You will need to perform the initial configuration with sp_configure )
sp_configure 'show advanced options', 1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
SELECT * FROM OPENROWSET ('Microsoft.ACE.OleDB.12.0',
'EXCEL 8.0;Database=C:\importacao.xlsx',
Planilha1$)
In the above select, OPEMROWSET
it will behave like a table, so you can do whatever you want, including popular tables with the fields you want.
SELECT COD_FUN, COD_PROCEDIMENTO INTO TabelaTeste
FROM OPENROWSET ('Microsoft.ACE.OleDB.12.0',
'EXCEL 8.0;Database=C:\importacao.xlsx',
Planilha1$)
Requirements
-
The Server (where SQL Server is installed) should have access to the folder where your Excel file is located; In the above example, "C: \" is directly the root of the server.
-
Check which Provider you have installed: