sql - BULK INSERT a xlsx file -


i have been struggling import .xlsx file while , cant seem figure out happening. follow steps find in other posts, , other tutorials.

i have simple .xlsx file now:

enter image description here

this the code run grab file , put temp table now:

if object_id('tempdb..#compare') not null     drop table #compare;  create table #compare (     name varchar(max)     ,lastname varchar(max) );   bulk insert #compare         'c:\users\michael\documents\taquanta\taqkanban - 44 - 3pm compare\compare.xlsx'                 (                 fieldterminator = '\t',                 rowterminator = '\n'     ) go  select * #compare c 

and results returned not expected :(

the results:

enter image description here

please let me know going wrong?

i've done powershell several times. adapt following.

$filename = "c:\users\michael\documents\taquanta\taqkanban - 44 - 3pm compare\compare.xlsx"; $excelconnstr = "provider=microsoft.ace.oledb.12.0;data source='$filename';extended properties='excel 12.0 xml;hdr=yes';" $excelconn = new-object system.data.oledb.oledbconnection($excelconnstr); $excelconn.open(); $excelcommand = new-object system.data.oledb.oledbcommand("select * [sheet1`$a5:ae]" ,$excelconn);  $adpt = new-object system.data.oledb.oledbdataadapter; $adpt.selectcommand = $excelcommand;  $dt = new-object system.data.datatable; [void]$adpt.fill($dt);   $sqlconnstr = "server=xxxxx;database=xxxxx;trusted_connection=true;"; $sqlbulkcopy = new-object system.data.sqlclient.sqlbulkcopy($sqlconnstr); $sqlbulkcopy.destinationtablename = "dbo.tablename" $sqlbulkcopy.writetoserver($dt); $sqlbulkcopy.close(); 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -