Evaluate narrow index keys by comparing clustered GUID and integer designs, measuring index pages, and preserving natural uniqueness.
Designing Your First Table: Columns, Keys and Data Types
Designing Your First Table gets easier when you decide what it must hold before you write any SQL. This post walks through naming, data types, NULL or NOT NULL, a primary key, a default and a check constraint on a small Customers table. It also shows what to leave for later.
What Is a Foreign Key, and What It Protects
What is a foreign key? It’s a column that must match a key in another table, and SQL Server refuses any value that has no match. This post shows the error it raises, the ON DELETE options, and why the foreign key column needs an index of its own.
Explicit Identity Values: Loading Rows With Their Old Keys
Moving rows and keeping their old keys? Here is the safe order of steps, and the counter check that saves you from a collision.
Create Constraints Quiz: What Does WITH NOCHECK Leave Behind?
This Create Constraints Quiz adds a CHECK constraint WITH NOCHECK to a table that already holds a bad row. The bad row stays, and the constraint is marked not trusted. A tested script proves it, shows what trust changes for the optimizer and lists four ways to create a constraint.
Surrogate Keys and Natural Keys
Surrogate keys keep warehouse history stable while natural keys preserve source identity; learn lookup, uniqueness, and change handling.
Large IN Lists: When a Temp Table Beats Thousands of Values
Pasting thousands of IDs into an IN list works, until it does not. See where the time goes and how to keep the answer the same with a temp table.







