What you will learn
A database needs both persistent data storage and a transaction log. The log supports recovery; it is not a disposable diagnostic file. You will create TutorialDB using the instance defaults, inspect the resulting files, and verify committed data. This replaces hard-coded legacy installation paths with observable settings.
Before you begin
Use an isolated SQL Server 2022 Developer lab on host1.sample.com and a current SQL Server Management Studio client. Developer edition is for nonproduction use. Connect with a dedicated lab administrator for setup; application access is tested separately. The examples use TutorialDB and synthetic rows only. GO is a client batch separator, not a Transact-SQL statement. Sample paths are on the database server, not your workstation.
1. Create the lab database once
USE master;
GO
CREATE DATABASE TutorialDB;
GO
USE TutorialDB;
GO
Run this on a clean lab where TutorialDB does not already exist. Inspect the instance default data and log directories first using the inventory lesson. Creation inherits relevant settings from model; neither the recovery model nor file placement should be guessed.
2. Inspect and plan file growth
SELECT name, type_desc, physical_name,
size / 128.0 AS size_mb, growth, is_percent_growth, max_size
FROM sys.database_files;
File size is reported in 8 KB pages, so dividing by 128 converts it to MB. When is_percent_growth is zero, growth is also a page count; otherwise it is a percentage. Choose an initial size and fixed growth increment from measured workload needs and available storage. Autogrowth is a fallback, not a capacity plan. The database service account must be able to access the directories.
3. Create and query a small fixture
CREATE TABLE dbo.Events (
event_id int NOT NULL CONSTRAINT PK_Events PRIMARY KEY,
message nvarchar(100) NOT NULL
);
INSERT dbo.Events(event_id,message) VALUES (1,N'ready');
SELECT event_id,message FROM dbo.Events;
A primary key makes the example row identifiable and prevents accidental duplicates. Execute the INSERT once. Open a second query window against TutorialDB and run only the SELECT to demonstrate that the committed row is visible outside the creating session.
4. Read the example output
The following is illustrative, normalized output, not a transcript from a customer system. Values depend on your release and lab state.
event_id message
1 ready
The deterministic row is a useful acceptance check; actual physical filenames and initial sizes are instance-specific.
Verify the result
Confirm TutorialDB is ONLINE in sys.databases, identify one ROWS file and one LOG file, and read the fixture from a separate session. Record free filesystem space outside SQL Server as well as logical file sizes.
Troubleshooting
An existing database or table error usually means a setup step has already run. Inspect that object instead of dropping it automatically. Permission-denied errors on CREATE DATABASE require the appropriate setup identity. File-creation failures can reflect directory permissions or unavailable storage.
Recovery and next steps
Keep TutorialDB for the subsequent security, backup, and maintenance lessons. For a failed creation, inspect server logs and any partially created resources before retrying. Do not delete an attached MDF or LDF file from the operating system.