Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

102


Part I: Laying the Foundations


Shortcuts and Bookmarks
Bookmarks are a great way to navigate large scripts. You can set bookmarks manually or
automatically using the Find command. Bookmarks work with double control key combina-
tions. For example, holding down the Ctrl key and pressing K and then N moves you to the
next bookmark. The Ctrl+K keys also control some of the other editing commands, such as
commenting code. You can also control bookmarks using the Edit ➪ Bookmarks menu or the
bookmark next and previous toolbar buttons. Table 6-1 lists useful shortcuts.

TABLE 6 -1 Useful Query Editor Shortcuts

Shortcut Description
Ctrl+Shift+R Refreshes IntelliSense
Ctrl+K, Ctrl +K Adds or removes a bookmark
Ctrl+K, Ctrl +A Enables all bookmarks
Ctrl+K, Ctrl +N Moves to the next bookmark
Ctrl+K, Ctrl +P Moves to the previous bookmark
Ctrl+K, Ctrl +L Clears all bookmarks
Ctrl+K, Ctrl +C Comments the selection
Ctrl+K, Ctrl +U Uncomments the selection
Ctrl+K, Ctrl +W Opens the Bookmark Window
Ctrl+K, Ctrl +X Inserts Code Snippet
Ctrl+K, Ctrl+S Inserts Code Snippet to surround code with

The Bookmark Window displays a list of all bookmarks and offers tools to control book-
marks, navigate bookmarks, and even to change the name of a bookmark.

Bookmarks are lost if the fi le is simply saved as a .sql fi le; however, if the query is saved
within a solution in the Solution Explorer, bookmarks are saved from session to session.

Query Options
When a batch is sent from Query Editor to SQL Server, it has several query option settings
that go with the batch. The defaults for these settings can be set in Tools ➪ Options ➪ Query
Execution ➪ SQL Server. The current query options can be viewed or changed in
Query ➪ Query Options, as shown in Figure 5-10.

Executing SQL Batches
As a developer’s tool, the Query Editor is designed to execute T-SQL batches, which are col-
lections of multiple T-SQL statements. To submit a batch to SQL Server for processing, use

c05 July 23, 2012 11:44 AM V1


c05.indd 102c05.indd 102 7/30/2012 4:14:51 PM7/30/2012 4:14:51 PM


http://www.it-ebooks.info
Free download pdf