Wanda Larangeira
Wanda Larangeira

Reputation: 69

Need help printing query results to a file/text

This SSMS newbie is trying to print the results of a query instead of having it directed to the grid I followed the following steps:

Management Studio -->> Tools -->>Options -->>

Query Results -->>General -->> Results to text and c:\works as Default location for saving query

Query Results -->>SQL Server -->> Results to text -->>Include column headers when copying or saving...

yet, when query is executed, I don't see the results at all could someone please shed the light my way as to how can I get the query results saved to a file that I can print later on?

Upvotes: 1

Views: 1217

Answers (3)

Kevin
Kevin

Reputation: 153

You don't want Results to Text. You want Results to File. Then, when you execute the query, you'll be prompted for the file name to save under.

Upvotes: 0

alroc
alroc

Reputation: 28154

If you send the results direct to file, you can't see them in the Results pane in SSMS.

You have three choices:

  • Results to Text (plain text, in the Results pane)
  • Results to Grid (grid view, with resizeable columns & rows similar to Excel)
  • Results to File (writes direct to file, results not displayed)

You can choose between these options from the Query -> Results menu, buttons on the Standard toolbar, or keyboard shortcuts (CTRL-T,CTRL-D, CTRL-SHIFT-F, in the order above). Select your output "mode", then execute the query.

With the first two options, you can right-click the results and save to a file from there. Or copy/paste elsewhere.

With Results to File, it will output the results in a file in your default location (c:\works\ in your case) but it should prompt you with the standard Windows File Save dialog.

Upvotes: 1

db_brad
db_brad

Reputation: 923

You need to select "Results to File" not "Results to Text". When you then go back and run your query, you will not see any query results, just a prompt for the file name you want to save the results as.

Upvotes: 0

Related Questions