MySQL had a nifty command SELECT ... INTO OUTFILE
that could write the result set into a file (CSV format or some other optional format).
I am currently using SQL Server Management Studio to query an MS-SQL backend server. I have multiple SQL queries and would like to write the output result set into a file. Is there any way I could store the results from a query directly into a file?
This question is related to
sql
sql-server
sql-server-2008
ui-select2
In SQL Management Studio you can:
Right click on the result set grid, select 'Save Result As...' and save in.
On a tool bar toggle 'Result to Text' button. This will prompt for file name on each query run.
If you need to automate it, use bcp tool.
Source: Stackoverflow.com