Sign in to save your place.
Learn the SSMS interface, create your first database, and run your first T-SQL command!
When you connect to SQL Server in SSMS, you see:
master!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.
In Object Explorer, right‑click Databases and choose New Database…
Enter a name (e.g. MyFirstDB or PracticeDB). Leave other options default. Click OK.
Expand Databases, right‑click your new database, and select New Query. The query window will use this database by default.
Always create and use your own database for assignments and practice. master holds server configuration; messing with it can break the instance.
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!
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.
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.
-- 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;
□ 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.
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).
Correct! master holds server configuration; use your own database for practice.
master is critical for the server; create a separate database for your work.
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.
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.
Where should a practice table live?