-1

How can we export or save multiple select statements in SQL Server?

As for example, if we have 3-4 select statements, how can we export or print them to a single .txt or .csv file?

In mysql we have

select * from person INTO OUTFILE 'c/person.txt'

to print to a file, but what is the equivalent for this in SQL Server? Is there any SQL query using which I can come to a solution?

N Borah
  • 1
  • 4
  • 1
    [8 Ways to Export SQL Results To a Text File](http://www.sqlservercentral.com/articles/Export/147145/) – Zohar Peled Mar 13 '19 at 11:38
  • 1
    `bcp`, `sqlcmd`, SSIS, to name a few. – Thom A Mar 13 '19 at 11:38
  • I have the select statements in a stored procedure, from which i want to export the select statement by giving a option in the procedure to print the required fields/statements – N Borah Mar 13 '19 at 11:44
  • Use DBeaver - has ability to export as csv. And it's cross SQL vendor compatible. – JGFMK Mar 13 '19 at 11:52

1 Answers1

0

Right click on the data output grid and select Save Results As...

If you want to export the results of the query without viewing the data grid you can got to Query->Query Options confirm your settings and then press Ctrl + Shift + F to export results to file.

Export CSV Data

GeersJ
  • 105
  • 2
  • 8