Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Bulk Insert from XLSX file extension?

Can anyone advise how to bulk insert from .xlsx file?

I tried the below query already:

BULK INSERT #EVB FROM 'C:\Users\summer\Desktop\Sample\premise.xlsx' 
WITH (FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', FIRSTROW = 2);

SELECT * FROM #EVB

I also tried with FIELDTERMINATOR like "**\t**", "**,**", "**;**", "**|**", but this doesn't work either.

Unfortunately, there is no error message.

like image 655
SƲmmēr Aƥ Avatar asked Oct 29 '12 15:10

SƲmmēr Aƥ


2 Answers

you can save the xlsx file as a tab-delimited text file and do

BULK INSERT TableName
        FROM 'C:\SomeDirectory\my table.txt'
            WITH
    (
                FIELDTERMINATOR = '\t',
                ROWTERMINATOR = '\n'
    )
GO
like image 185
wootscootinboogie Avatar answered Oct 22 '22 03:10

wootscootinboogie


You need to use OPENROWSET

Check this question: import-excel-spreadsheet-columns-into-sql-server-database

like image 21
Turque Avatar answered Oct 22 '22 05:10

Turque