I want to export select * from table
results to a text file from the command line in linux. How should I do this?
Thanks, Jean
However, if you prefer to export SQL query results to a text file via a Wizard, we have your back. To begin with, right-click the database in SQL Server Management Studio or SSMS. Then, select the Import or Export data option and head to Export Data under Tasks. Next, open the SQL Server Import and Export wizard.
Click Query, and then click Results to File. Enter and then execute the SQL statement. In the Save Results dialog box, specify the following settings: Save In: Select a directory in which to save the file.
look at link
you only need to add this to the query
select * from table INTO OUTFILE '/tmp/myfilename.txt'
you can improve this to csv file (using it in excel latter)
like :
INTO OUTFILE '/tmp/myfilename.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With