Sign in to save your place.

MODULE 3 OF 12

SSMS Tour & First Database

Learn the SSMS interface, create your first database, and run your first T-SQL command!

SSMS Overview

When you connect to SQL Server in SSMS, you see:

  • Object Explorer (left) — Browse databases, tables, columns, and other objects. Expand folders to see what's on the server.
  • Query window — Where you type T-SQL. Open it with New Query or by right‑clicking a database and choosing New Query.
  • Execute button (or F5) — Runs the T-SQL in the current query window. Results appear below.
  • Database dropdown — Shows which database your query runs against. Always pick the right one; don't run exercises in master!

Create Your First Database

master is a system database. Don't use it for your own data—if it gets corrupted or full, the whole server can be at risk. Create a separate database for your work.

Create a database

1
Right‑click Databases

In Object Explorer, right‑click Databases and choose New Database…

2
Name it

Enter a name (e.g. MyFirstDB or PracticeDB). Leave other options default. Click OK.

3
Open a query window for that database

Expand Databases, right‑click your new database, and select New Query. The query window will use this database by default.

Don't Use master for Practice

Always create and use your own database for assignments and practice. master holds server configuration; messing with it can break the instance.

Run Your First Command

In the new query window, type:

SELECT DB_NAME() AS DatabaseName;

Click Execute (or press F5). The result shows the name of the database you're connected to. If you see the name you gave (e.g. MyFirstDB), you're all set!

Explain Like I'm 5

DB_NAME() is a function that asks: "What database am I in?" SQL Server answers with one row showing that name. It's a simple way to confirm you're in the right place before you start creating tables and writing real queries.

SSMS Layout

Left: Object Explorer — Servers → Databases → YourDB → Tables, etc.

Center: Query window — type T-SQL here.

Bottom: Results — rows returned by SELECT (or "Commands completed" for other statements).

Top toolbar: New Query, Execute (▶), database dropdown.

Commands to Try

-- Which database am I using?
SELECT DB_NAME() AS DatabaseName;

-- List all databases on the server (run in any database context)
SELECT name FROM sys.databases ORDER BY name;

Practice

Checklist

□ Create a new database (e.g. PracticeDB) via Object Explorer → Databases → New Database.

□ Right‑click that database → New Query.

□ Run SELECT DB_NAME() AS DatabaseName; and confirm the result shows your database name.

□ Run SELECT name FROM sys.databases ORDER BY name; and see the list of databases.

Quiz

1. Where do you type T-SQL in SSMS?

In the Query window
In Object Explorer
In the Results pane only
In the database dropdown

Correct! The query window is where you type and run T-SQL.

You type T-SQL in the Query window, then run it with Execute (F5).

2. Why shouldn't you use the master database for your own tables?

It's a system database; damaging it can affect the whole server
It's too slow
It doesn't support tables
It's read-only

Correct! master holds server configuration; use your own database for practice.

master is critical for the server; create a separate database for your work.

3. What does DB_NAME() return?

The server name
The name of the current database
The list of all databases
The current user name

Correct! DB_NAME() returns the name of the database you're connected to.

DB_NAME() returns the current database name, not the server or user.

October 2026: the query window

SSMS 22 changes the shell. The work is still the same. Object Explorer is the tree. A query window is where T-SQL runs. Results come back in the grid. Do not create practice tables in master. Create a database named something like Practice and use that.

F5 or the Execute button runs the batch. Highlighting a few lines runs only those lines. That surprise is older than SSMS 22, and it still bites people.

SELECT DB_NAME() AS current_database;

Try this. Create a database that is not master, select it in the toolbar, and run SELECT DB_NAME();. The name in the result should be the database you created.

Knowledge check

Where should a practice table live?