- February 8, 2017
- Posted by: iSummation Team
- Category: Uncategorized
Today we had a requirement to insert data into database from excel sheet. I used POI Utility to read data from excel sheet and it works fine but problem occurs if the recordset has around thousands of record and request time out error occurs. So I was googling for a solution and came across sql server’s in-built function ‘OPENROWSET‘.Using this function we can read and write excel sheet from sql server.
Follow the procedure below to read or write excel’s data using this functionality;
To import Excel file, we need to do following:
1. Put Excel file on server, means we need to put files on server,
if we are accessing it from local.
2. Write following TSQL, to read data from excel file.
SELECT * FROM OPENROWSET(‘Microsoft.Jet.OLEDB.4.0’,
OR Write data from excel sheet.
SELECT * INTO Temp
FROM [sheet1$]’) [/code]