I have a sql file which has a lot of insert statements (1000+),
eg
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.
如果您在某处安装了mysql并且安装了phpMyAdmin,则只需导入.sql文件,然后直接从phpMyAdmin中将表导出为.xls文件即可。
edit: If you want to extract the data from the Insert statements without actually running them, you could:
If you are not keen on installing any tools you could try this...its simple but needs some regex matching with trial and error for strings.
Side Note : you could also try asking your client to send it in excel henceforth its usually available in most data providers.
You mean export the values?
Assuming you're using the SQL server + tools the simplest method would be to
select * from pubs_for_client
You'll have to set the column widths yourself, and if you have number-as-a-string columns you want to keep as strings (eg to preserve leading zeroes) then you'll need to set the receiving column type first.
If not, and if you can't use similar tools for your database, you can use regexps or just use your text editor to convert your SQL file into a CSV which Excel will read. You'd also have to edit out quotes from values and nulls and doubled-to-quote apostrophes. Unfortunately you can't then specify column types in advance and you would eg lose leading zeros on numbers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.