April 6, 2011 at 4:27 am
Hello,
I'm stuck at the issue that format the excel file to fmt/XML file via BCP.
I have to import lots of EXCEL files data into the table in the Database. openquery doesn't work on my machine, I'm thinking that we can use bulk insert to load data into the table in the database. But I have to create the table before I use bulk insert. I did some searchs on the internet, seems that I can use following way to load the data into table dynamic, and don't need to care the excel column struncture. But I don't know how to generate the .fmt file... is there anybody can share some info to format the excel file to .fmt file? Really appreciated if you can share anything with me. Thanks a lot.
SELECT * into FROM OPENROWSET (BULK '\\localhot\TestExcel\FiscalCSV.csv', FORMATFILE = '\\localhot\TestExcel\FiscalCSV.Fmt') AS Z
Thanks
Lindsay
April 6, 2011 at 12:02 pm
Just to clarify, a csv file is not the same as Excel file as noted by the xls and xlsx extensions. CSV stands for Comma-Separated Value and is nothing more than a plain-text file. When Excel is installed it creates an association in Windows so when you double-click a file with a .csv extension the file opens in Excel...but you do not need Excel to create csv files.
Back to your issue, you'll need to create a format file (also nothing more than a text file but saved with a .fmt extension) that describes your csv file. Here is a good article to get you started: http://msdn.microsoft.com/en-us/library/ms191516.aspx
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
April 6, 2011 at 7:29 pm
Thanks for your response opc.three:)
The link is useful, but I saw it only have the sample to fromat a table/view in the database into the .fmt file, is there any way to format a Excel/CSV file into a .fmt file?
Thanks
Lindsay
April 7, 2011 at 2:11 am
I have found another to create the table for excel. This thread can be closed:)
Thanks
Ling
April 7, 2011 at 7:59 am
Great, I am happy you found a solution. Would you mind posting what you did so others who find this post from a search engine can benefit as well?
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
April 7, 2011 at 8:14 am
Sure
I only use the openrowset (the query is something like below) to create the table for excel.
Thanks
Lindsay
SELECT * INTO Test.dbo.sheet2 FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=\\localhost\TestExcel.xlsx', [Sheet1$])
April 7, 2011 at 9:11 am
Your original post references a file with a .csv extension...did you switch to using a real Excel Workbook file?
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
April 10, 2011 at 11:40 pm
Basically, there is no CSV file, my original file is Excel. Bacause BCP doesn't work on Excel, I convert my Excel file to CSV. Now I found the Excel can be read by openrowset directly, so this solution works for me:)
Thanks
Lindsay
December 2, 2015 at 10:50 am
I have the same problem importing data to my table on SQL Azure server. My data are in an excel file and cannot use BCP utility to import them to my table. I tried to use OPENROWSET but I get this error "'OPENROWSET' rowset provider not supported in this version of SQL Server."
Now my challenge is creating .fmt since my data is not in the tables.
Or There might another way of importing bulk data to my tables in SQL Azure
Please let me know if you have any suggestions
Thank you
December 2, 2015 at 8:13 pm
You can use SSIS or the Import/Export Wizard (based on SSIS) from within SSMS.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
December 3, 2015 at 11:37 am
Thank you for your reply.
I have windows 10 and i could only download ssms express and it doesn't have import under task.
I downloaded SSDT for Visual Studio 10, when I open the Data Tool Operations it just trying to read the data structure after that it doesn't give me any options to import data.
What would be the steps to use ssdt from visual studio 10.
From Command line is there any specific script to run. because Bulk insert and bcp doesn't work as I explained before that my data is in a excel sheet
Thank you
Shelir
December 3, 2015 at 3:35 pm
SSMS Express does contain the Import/Export Wizard. Try right-clicking on a Database, then Tasks, then Import Data...
The only limitation with SSMS Express is you cannot save the resulting SSIS Package dynamically generated by the Wizard.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
December 4, 2015 at 12:00 pm
Thank you for your reply.
Unfortunately I didn't get the Import/Export option from the task list, may be is because I have Windows 10 installed.
But alternatively I installed Import / Export wizard and used it to import my excel data to the database.
Warm Regards
Shelir
December 4, 2015 at 3:55 pm
Good deal. Happy you got something working. For others that might run across this thread, could you share the link to the installer you found that eventually let you run the Wizard?
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
December 7, 2015 at 8:17 am
I installed both Import and Export Data Wizard (64 bit) and Import and Export Data Wizard (32 bit). Since Access and Excel have only 32 bit version provider the 32 bit wizard worked for me
Here is a link to learn more: https://msdn.microsoft.com/en-us/library/ms141209.aspx
Thank you
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply