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 ServerBulk changes & set operations

Combine results while retaining duplicates

SQL Server: UNION ALL does not spend work removing equal rows.

SQL Server✓ Tested
SQL ServerText cleanup & matching

Combine text values with a separator

SQL Server: Use the concatenation operator supported by the selected SQL dialect.

SQL Server✓ Tested
SQL ServerSchema design & transactions

Commit multiple related changes together

SQL Server: The first transaction prepares the fixtures. The second commits both updates as one unit.

SQL Server✓ Tested
SQL ServerSubqueries & ranked selection

Compare a row with its own group average

SQL Server: A correlated aggregate computes a different comparison value for each group.

SQL Server✓ Tested
SQL ServerReporting & grouped calculations

Compute an integer weighted average

SQL Server: Multiply before summing and guard a zero total weight with NULLIF.

SQL Server✓ Tested
SQL ServerBulk changes & set operations

Copy selected rows into another table

SQL Server: INSERT SELECT performs a set-based copy with an explicit destination column list.

SQL Server✓ Tested
SQL ServerReporting & grouped calculations

Count distinct values within a result

SQL Server: COUNT DISTINCT counts distinct non-null values.

SQL Server✓ Tested
SQL ServerReporting & grouped calculations

Count rows satisfying separate conditions

SQL Server: SUM over CASE expressions calculates several conditional counts in one scan.

SQL Server✓ Tested
SQL ServerGetting Started

Count the rows in a table

SQL Server: COUNT(*) includes every row, including rows with NULL columns.

SQL Server✓ Tested
SQL ServerGetting Started

Create a table and insert its first row

SQL Server: Define column types and a primary key, then insert one row using an explicit column list.

SQL Server✓ Tested
SQL ServerSchema design & transactions

Create an index for an equality filter

SQL Server: A nonunique index can support lookups on a frequently filtered column.

SQL Server✓ Tested
SQL ServerSchema design & transactions

Create an index matching filter and ordering columns

SQL Server: Place the equality-filter column before the ordering column in this composite index.

SQL Server✓ Tested