Import Data From Excel File Into Db Sql

[Solved] Import Data From Excel File Into Db Sql | Vb - Code Explorer | yomemimo.com
Question : Importing excel data into SQL Server

Answered by : bewildered-badger-jh2zw9xeie70

# For file excel 2007 version (*.xlsx)
INSERT INTO MyTable
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=D:\test.xlsx', [Customer$])
# For file excel 97-2003 version (*.xls)
INSERT INTO MyTable
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\test.xls', [Customer$])

Source : https://stackoverflow.com/questions/8814739/importing-excel-data-into-sql-server-2008 | Last Update : Fri, 13 May 22

Question : Import data from excel file into DB - SQL

Answered by :

declare @SQL nvarchar(max) = '
CREATE TABLE #TempTable
( [Field1] nvarchar(max) NULL, [Field2] nvarchar(max) NULL, [Field3] nvarchar(max) NULL );
BULK INSERT #TempTable FROM ''<FullPath>\FileName.csv'' WITH --if the path is in the network - need to write the Full-path of the drive
(
KEEPIDENTITY,
FIELDTERMINATOR = '','',
MAXERRORS = 10000,
KEEPNULLS,
ROWTERMINATOR=''\n'',
FIRSTROW = 2,
CODEPAGE = ''1255''
);
select * from #TempTable
Insert into TableNameInDB(Field1,Field2,Field3)
select * from #TempTable
'
EXEC sp_executesql @SQL

Source : https://stackoverflow.com/questions/73304312/how-to-import-data-from-excel-file-into-sql-server-db-by-script/73317703#73317703 | Last Update : Thu, 18 Aug 22

Answers related to import data from excel file into db sql

Code Explorer Popular Question For Vb