FIND YOUR NEXT FEW LINES

Results for “SQL Server”

Small, practical examples. Search by task or narrow things down below.

502 snippets foundClear filters
SQL ServerGetting Started

Delete one row from a practice table

SQL Server: Restrict DELETE with a primary-key condition and verify the remaining row count.

SQL Server✓ Tested
SQL ServerBulk changes & set operations

Delete rows selected by a related table

SQL Server: A correlated EXISTS limits the delete to explicitly listed records.

SQL Server✓ Tested
SQL ServerGetting Started

Display a fallback for missing data

SQL Server: Return a supplied label when a column contains NULL.

SQL Server✓ Tested
SQL ServerReporting & grouped calculations

Distinguish row count from non-null value count

SQL Server: COUNT(*) includes every row while COUNT(column) skips NULL values.

SQL Server✓ Tested
SQL ServerWindow analytics

Divide an ordered result into numbered buckets

SQL Server: NTILE distributes rows across buckets; include a unique tie-breaker for deterministic assignment.

SQL Server✓ Tested
SQL ServerConstraints & defaults

Enforce a bounded numeric range

SQL Server: A named CHECK constraint keeps numeric values inside an inclusive interval.

SQL Server✓ Tested
SQL ServerSchema design & transactions

Enforce a relationship between two columns

SQL Server: A row-level CHECK can require a start value to be no greater than an end value.

SQL Server✓ Tested
SQL ServerSchema design & transactions

Enforce uniqueness with a dedicated index

SQL Server: A unique index rejects a duplicate combination independently of query plans.

SQL Server✓ Tested
SQL ServerSchema design & transactions

Expose a reusable filtered view

SQL Server: A view stores a query definition rather than a snapshot of its rows.

SQL Server✓ Tested
SQL ServerGetting Started

Filter by a numeric comparison

SQL Server: Keep rows whose quantity exceeds a chosen threshold.

SQL Server✓ Tested
SQL ServerGetting Started

Filter groups after aggregation

SQL Server: Use HAVING to test a group’s calculated total.

SQL Server✓ Tested
SQL ServerReporting & grouped calculations

Filter rows before grouping

SQL Server: WHERE limits the rows contributing to the aggregate; it differs from filtering completed groups with HAVING.

SQL Server✓ Tested