Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export SQL file into Excel

I have a sql file which has a lot of insert statements (1000+),

e.g.

insert into `pubs_for_client` (`ID`, `num`, `pub_name`, `pub_address`, `pub_tele`, `pub_fax`, `pub_email`, `publ_website`, `publ_vat`, `pub_last_year`, `titles_on_backlist`, `Personnel`) values('2475','2473','xxx xxx xxx','xxx xxx, xxxx, xxxx, xxxx, ','000000 ','0000 ',NULL,NULL,NULL,NULL,NULL,NULL);

My client wants these in an excel file.

Is it possible to extract the information from this sql file and import it into an excel spreadsheet? I'm using excel 2007.

like image 306
109221793 Avatar asked Sep 29 '10 10:09

109221793


People also ask

Can we export SQL query results to Excel?

Method Number 1 – Copy Grid results and paste into Excel After ensuring results to grid turned on, Execute your query, right-click the top left-hand corner of the results grid. Right-click on the database you want to export from. Then Select tasks and “Export Data”. The SQL Server Wizard will startup.

How do I export a database to Excel?

On the External Data tab, in the Export group, click Excel. In the Export - Excel Spreadsheet dialog box, review the suggested file name for the Excel workbook (Access uses the name of the source object). If you want, you can modify the file name. In the File Format box, select the file format that you want.


2 Answers

If you have a mysql installation somewhere and phpMyAdmin, just import the .sql file and export the table as .xls file directly from within phpMyAdmin.

like image 121
cweiske Avatar answered Sep 25 '22 03:09

cweiske


edit: If you want to extract the data from the Insert statements without actually running them, you could:

  • Save the SQL file as a CSV file
  • Open it in Excel and it will automatically split the statements up into bits using the commas
  • Most of the columns to the left of the data wont be worth keeping, so delete them
  • The right-most columns should contain the data
like image 34
codeulike Avatar answered Sep 22 '22 03:09

codeulike