- Making the Connection
- Navigating SQL Server Management Studio
- Creating the Example Tables
- Selecting a Database
- Learning About Databases and Tables
- Summary
Navigating SQL Server Management Studio
Because we’ll be spending so much time in Microsoft SQL Server Management Studio, a quick tour of the tool is worthwhile:
At the top of the screen is a toolbar containing lots of buttons. One of those buttons is labeled New Query, and when you click on it you open a window in which you can type and execute SQL. You’ll be using this button and window extensively.
The left column is the Object Explorer used to browse databases, tables, and more. You can right-click on objects to see their details, edit them, and perform other tasks too. Click on the + next to Databases to see the databases that have been already created.
On the left of the toolbar, right above the Object Explorer, is a drop-down box (the first time you open Microsoft SQL Server Management Studio this box will likely contain the word master). This drop-down box is used to select the database you want to work with (as you will recall from Lesson 1, a single DBMS can work with lots of databases). We’ll create our own database shortly, which will then appear in this drop-down box.
On the right side of the screen is a Properties panel. If it is not visible, don’t worry, it’ll open when there are properties to be displayed.
Not visible initially is the Results panel. This appears under the Query window and displays query results when there are results to show.
There are many ways to use Microsoft SQL Server Management Studio, but here are the basic steps needed to enter and execute SQL statements:
As just noted, the New Query button at the top-left of the screen opens a window in which SQL statements are entered.
As T-SQL statements are typed, Microsoft SQL Server Management Studio automatically color-codes the statements and text (this is an invaluable troubleshooting tool because it lets you quickly spot typos or missing quotes and so on).
To execute (run) a statement, click the Execute button (the one with the red exclamation point on it). You can also press F5 or Ctrl+E to execute a statement.
To verify that a SQL statement is syntactically correct (without executing it), click the Parse button (the one with the blue checkmark on it).
Microsoft SQL Server Management Studio displays statement results at the bottom of the screen. Results may be displayed in a grid (the default behavior), as plain text, or saved to a file. You can switch between these modes by clicking the appropriate toolbar buttons.
In addition to displaying statement results, Microsoft SQL Server Management Studio also displays status messages (the number of rows returned, for example) in a second tab labeled Messages.
To obtain help, click the statement you need help with and press F1.