Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

101


Chapter 5: SQL Server Management and Development Tools


5


■ (^) You can drag and drop column names from the Object Explorer tree onto the query window.
This allows you to quickly pick and choose specifi c columns for a query without having to
manually type out each column name.
■ (^) If the default size of the text is too small, hold down the Ctrl key and use your mouse scroll
wheel to increase/decrease the size of the font.
■ (^) When more documents exist than can display as tabs, the easy way to select the correct
tab is to use the Active Documents drop-down list, at the far right of the Query Editor next
to the close document X button. This is also the best way to see if a script is still executing,
but it does sometimes reorder the tabs.
■ (^) If there’s an error in the script, double-clicking the error message jumps to a spot near
the error.
■ (^) Use uppercase for all reserved words in the outer query, and then use PascalCase (sometimes
called CamelCase) for user-defi ned objects and reserved words in subqueries.
■ (^) IntelliSense Rocks! ’Nuff said.
■ (^) Use code outlining to collapse large sections of code. The Code Outliner can collapse
multiline statements.
■ (^) IntelliSense and Code Outlining can be turned off in Tools ➪ Options ➪ Tex t
Editor ➪ Tr an s ac t-SQL ➪ Advanced.
■ (^) Dragging the folder named Columns (listed under a table in the Object Explorer) onto the
query window will automatically list out all the columns in comma-delimited order. This can
be a great time saver if you’re trying to pick and choose specifi c columns for a query and
don’t want to manually type out each column’s name.
■ (^) The Query Editor provides a quick visual indicator of lines that have been edited. The Track
Changes Indicator displays a thin yellow bar to the left of the line if the text is modifi ed and
a green bar if that change has been saved.
■ (^) Use the SQLCMD toolbar button or Query ➪ SQLCMD Mode menu command to switch
the editor to work with SQLCMD utility scripts.
■ (^) While working with T-SQL code in Query Editor, you can get Books On Line (BOL) keyword
help by pressing F1.
■ (^) The new SQL Snippets feature is awesome! It’s a quick way to generate T-SQL code. You
can access this using the keyboard shortcut Ctrl+K,Ctrl+X, or right-clicking the Query
Editor window and selecting Insert Snippet. You can also assign keyboard shortcuts for
your favorite code snippets!
Out-of-the- box, Management Studio’s Query Editor does not provide automatic formatting of T-SQL. Some free web-
sites enable you to submit a SQL statement and will format the code. But consider using a third-party tool like SQL
Prompt from Red Gate, highly recommended. If you don’t want to purchase a third-party tool there are also free web-
sites like http://format-sql.com that allow you to copy/paste code and have it formatted for you.
c05 July 23, 2012 11:44 AM V1
c05.indd 101c05.indd 101 7/30/2012 4:14:50 PM7/30/2012 4:14:50 PM
http://www.it-ebooks.info

Free download pdf