Excel 2010 data import from mysql - mysql

I'm trying to import data from a MySQL database into an Excel workbook via an ODBC Data Source.
I have a big problem with the time(3) fields from MySQL. Excel imports the content not as expected. As first try, Excel cut the milliseconds off. Then I edited the query at the specific fields to:
DATE_FORMAT(jobstat_0.PreProcessingQueued,'%T,%f')
This puts something like:
00:00:00,156000
That's what I expected, but I can not change the format in Excel.
Excel interprets the content as text, and if I change to the specific time format, Excel does not care...
I need to correct that to get Pivot Tables working. As a result there are Divide By Zero errors in my Pivot Table.
May be someone had something like that?

Related

Access Export to CSV, trouble keeping leading zeros, 55-60 Million Records

Let me preface this by saying yes, I do need all of the records. It's part of a FOIL request. Not necessarily in one worksheet or file.
I'm having trouble figuring this out. I am currently able to export about 500k records at a time without timing out or exceeding access file size(I think this is due to working with state systems legacy data) or worrying about excel row limit. I can preserve column headers but lose leading zeros in one field.
This is done using the export wizard to text file. I change the destination file name ending from .txt to .csv and that gives me the option to keep headers. On the preview of the .csv file in the wizard and when opened in notepad it shows the field with leading zeros correctly with double quotes around it, for example "00123456" but then when opened in excel it shows as 123456. If I update the row from General format to Text the contents remain the same.
I have tried VBA method of DoCmd.TransferSpreadsheet but when I try to run it I am prompted with a Macros box. And honestly am less familiar with VBA than in am SQL. Overall I consider myself a novice.

SSIS - Flat File Destination data formatting

If I have a column of type DT_DBDATE or DT_DBTIMESTAMP, and I write the data to a file using a Flat File Destination component, the resulting date formatting will YYYY-MM-DD HH:MM:SS. I've experimented with changing the package locale and changing the datatype in the Flat File Connection Manager, but these don't seem to have any effect.
What determines this format and is there any way I can change the default formatting?
PS. I know I can use Data Conversion and Derived Column components to change the data types/formats. The point is we have +150 packages and get too many errors when someone forgets to do the conversion or does it incorrectly.
We're using SSIS 2012.
I had a similar issue while using SSIS 2008 with SQL Server 2008 R2. If you are trying to generate a CSV file, I would recommend first, at the database level, to store the value in the desired format. This means, for instance, if you want to display a column where the current date is in the format YYYY-MM-DD, then you should use the appropriate code to store that value. Using T-SQL will be: convert(varchar(10), cast(GETDATE() as date), 126). Double check that the value was stored in the desired format by reading the table. Now it comes the tricky part: no matter what you are using in SSIS for transforming the dates, if you open the CSV using Excel, then Excel is going to display the dates using the format was set for the operating system. Don't panic, just don't save that file when you want to close it. Instead, if you open the CSV using Notepad or Notepad++, you should be able to see the date columns right in the format you used for storing them in the database.

Importing data from MySQL to Excel

I have data in excel sheet (CSV format) and I have imported this data into Mysql and filtered the data based on dates (only 2014 and 2015) years have been selected.
The client wants data back in excel. So, I have to import the data which I had extracted based on dates into excel. I believe this would be a temporary table. So, how do we import the temporary tables to excel.
I don't know how to use mysql to excel converter in this case, as the temporary table is being used.
Here is a software by MySQL to handle that
https://www.mysql.com/why-mysql/windows/excel/
MySQL for Excel makes the task of getting MySQL data into Excel a very
easy one; there are no intermediate CSV files required, only a couple
of clicks and data will be imported to Excel. MySQL for Excel supports
importing data from tables, views and stored procedures.
The easiest way of doing this could be as follows
select <fieldnames>
from <temporary table>
Then copy and paste the results into excel. save as excel format, and voila!
Edit: if you are using a tool like phpMyamin, you can just export the results of your query into the desired format. If you want the headers, choose "include column names" in the advanced" export.
If you just need a document that opens in excel you could export the tables as a CSV file from mysql.
http://www.mysqltutorial.org/mysql-export-table-to-csv/
If you have to actually create an excel worksheet then you would have to use a library based on what programming language you are using to convert the data to an excel spreadsheet.

SSIS - Export data from Excel to sql table

When i am trying to export data from excel to sql table using ssis,the all rows are inserted . But,when i am inserting a data of length greater than 255 to excel it's giving truncation error. In output column i altered it to 500. in External column input i can't alter it. In my excel sheet there is 2808 rows..but when this error is generating its only inserting 1632 rows and whole other rows are getting truncated....
If any one knows about this,please help me..I am really stuck on this....
Thanks..
Try sorting your data by length eg longest first.
Excel import/export is very buggy in SSIS.
Sometimes the only option is to write VBA script and run it from excel itself

Import Excel data to SQL Server

What is the correct way of importing data from Excel 2007 file to SQL Server database 2008? The data from excel file should be transferred successfully even if the data in Excel file is changed / replaced with different data except the column name at first row.
Excel is very finicky about how you remove rows from it. Your best bet is to select all rows below the column headers and right click and delete. If you simply clear contents and then don't paste in as many rows, it looks to SSIS like you have rows with nulls in them which sometimes causes the types of errors you are seeing.