background preloader

SQL

Facebook Twitter

Retrieving column names using sql query. Mysql - Parsing the output of mysqldump to create CSV files with field name headers. Exporting MySQL query results to a CSV File | Yet Another Site. 3.2 Entering Queries. Export CSV directly from MySQL. Dump a mysql database to a plaintext (CSV) backup from the command line. Save MySQL query results into a text or CSV file. MySQL provides an easy mechanism for writing the results of a select statement into a text file on the server. Using extended options of the INTO OUTFILE nomenclature, it is possible to create a comma separated value (CSV) which can be imported into a spreadsheet application such as OpenOffice or Excel or any other applciation which accepts data in CSV format.

Given a query such as SELECT order_id,product_name,qty FROM orders which returns three columns of data, the results can be placed into the file /tmo/orders.txt using the query: SELECT order_id,product_name,qty FROM orders INTO OUTFILE '/tmp/orders.txt' This will create a tab-separated file, each row on its own line. SELECT order_id,product_name,qty FROM orders INTO OUTFILE '/tmp/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' In this example, each field will be enclosed in “double quotes,” the fields will be separated by commas, and each row will be output on a new line separated by a newline (\n). How do I load text or csv file data into SQL Server?