12.07.2015 Views

Querying Microsoft® SQL Server® 2012 - Advanced Technology ...

Querying Microsoft® SQL Server® 2012 - Advanced Technology ...

Querying Microsoft® SQL Server® 2012 - Advanced Technology ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1-16 Introduction to Microsoft <strong>SQL</strong> Server <strong>2012</strong>Executing QueriesTo execute T-<strong>SQL</strong> code in SSMS, you first need to open the .sql file that contains the queries, or type yourquery into a new query window. Then decide how much of the code in the script is to be executed:• Select the code you wish to execute.• If nothing is selected, SSMS will execute the entire script, which is the default behavior.Once you have decided what you wish to execute, you can run the code by doing one of the following:• Clicking the Execute button on the SSMS toolbar.• Clicking the Query menu, then clicking Execute.• Pressing the F5 key, the Alt+X keyboard shortcut, or the Ctrl+E keyboard shortcut.By default, SSMS will display your results in a new pane of the query window. The location andappearance of the results can be changed in the Options box accessible from the Tools menu. To togglethe display of the results and return to a full-screen T-<strong>SQL</strong> editor, use the Ctrl+R keyboard shortcut.SSMS provides several formats for the display of query results:• Grid, which is a spreadsheet-like view of the results, with row numbers and resizable columns. You canuse Ctrl+D to select this before executing a query.• Text, which is a Windows Notepad-like display that pads column widths. You can use Ctrl+T to selectthis before executing a query.• File, which allows you to directly save query results to a text file with an .rpt extension. Executing thequery will prompt for a location for the results file. The file may then be opened by any applicationthat can read text files, such as Windows Notepad and SSMS itself. You can use Ctrl+Shift+F to selectthis before executing a query.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!