Database Reference
In-Depth Information
Changing the Query Window Focus
To focus on a particular database in Object Explorer, you need to expand the database folder and select a
database from the expanded treeview. To focus on a particular database in the query window, use the Available
Databases dropdown box (circled in Figure 5-10 ). This may be hard to spot because the name of the dropdown
box is not shown, it can be repositioned on the toolbar, and the selected database may be different than expected.
The Master database is typically displayed, but you can of course change this. In Figure 5-10 , we have selected
DWWeatherTracker instead, which causes the query window to be focused on that database.
Figure 5-10. Using the query window
Although we are not showing it in Figure 5-10 , you can also change the focus to a database by executing
the command: USE DWWeatherTracker. Looking at the status panel at the bottom of the query window tells you
which database is currently in focus.
Executing a Query
After you have added code to the query window, you are then able to execute that code by clicking the “! Execute”
button, as shown in Figure 5-10 . You can also execute a query using the keystrokes Alt + X or Ctrl + E.
Importan We do not recommended using the Debug button (with the green arrow) to execute your code. A de-
bugging session can start other processes and complicate what you are working on. If you are a .nET programmer,
you know that this is contrary to how you normally run code in Visual Studio in C# or VB.nET applications. neverthe-
less, it is important to remember that while working in SQL Server Management Studio, execute your code with the
“! Execute” button rather than debugging it.
 
 
Search WWH ::




Custom Search