Results for “SQL Server”
Small, practical examples. Search by task or narrow things down below.
Read the next row’s value
SQL Server: LEAD reads a later ordered row without a self join and supports a fallback at the end.
SQL Server✓ Tested
Read the smallest and largest values
SQL Server: Use MIN and MAX without sorting and fetching every row.
SQL Server✓ Tested
Read updated base-table values through a view
SQL Server: An ordinary view reflects later changes to its underlying data.
SQL Server✓ Tested
Reference a parent identified by two columns
SQL Server: A composite foreign key checks the complete referenced key rather than either column independently.
SQL Server✓ Tested
Reject a negative quantity with CHECK
SQL Server: Combine NOT NULL and CHECK because an unknown NULL check result is normally accepted.
SQL Server✓ Tested
Reject duplicate business identifiers
SQL Server: A UNIQUE constraint protects a business key independently of the primary key.
SQL Server✓ Tested
Remove dependent rows with a declared cascade
SQL Server: ON DELETE CASCADE removes children when their referenced parent is deleted.
SQL Server✓ Tested
Remove duplicate result values
SQL Server: Use DISTINCT when repeated category values are not useful.
SQL Server✓ Tested
Remove duplicate values while keeping the smallest key
SQL Server: Identify retained keys in a grouped subquery before deleting other copies.
SQL Server✓ Tested
Remove surrounding spaces from text
SQL Server: TRIM removes leading and trailing space characters by default.
SQL Server✓ Tested
Repeat the first ordered value beside each row
SQL Server: FIRST_VALUE reads the first value in the current window frame.
SQL Server✓ Tested
Replace a literal substring
SQL Server: REPLACE performs a literal replacement rather than a regular-expression substitution.
SQL Server✓ Tested