| Feature | Key Syntax / Pattern | When |
|---|---|---|
| CTE | WITH cte AS (SELECT …) SELECT … | Recursive hierarchies, readability |
| Window | ROW_NUMBER() OVER (PARTITION BY … ORDER BY …) | Ranking, running totals, lag/lead |
| JSON | JSON_VALUE / OPENJSON / FOR JSON PATH | Semi-structured data, LLM payloads |
| REGEXP | REGEXP_LIKE(col, pattern) | Pattern matching (Fabric SQL) |
| Fuzzy | EDIT_DISTANCE(a, b) | Typo tolerance, similarity search |
| Graph | MATCH (node1-(edge)->node2) | Social, recommendation graphs |
| Error | BEGIN TRY … END TRY BEGIN CATCH THROW END CATCH | Stored procedures, RAG callers |
| Object | Key Facts |
|---|---|
| View | WITH SCHEMABINDING for indexed views. Updatable if single-table, no aggregates. NOT WITH CHECK OPTION trap. |
| Inline TVF | Returns table, single SELECT. Optimised like a view — prefer over multi-statement TVF. |
| Multi-stmt TVF | Uses table variable. Optimizer can't see row count — cardinality issues. Avoid if performance matters. |
| Scalar UDF | Inhibits parallelism. Use inline TVF or computed column instead where possible. |
| Stored Proc | Input/output params. sp_executesql for parameterized dynamic SQL. Core RAG executor. |
| AFTER Trigger | Fires after DML. Uses inserted/deleted pseudo-tables. Good for audit, embedding update. |
| INSTEAD OF | Replaces DML. Needed for views. Risky — easy to break insert logic. |
| SEQUENCE | NEXT VALUE FOR seq. Can gap-skip on rollback. Useful across tables (unlike IDENTITY). |
| Feature | Syntax / Config | Notes |
|---|---|---|
| RLS | CREATE SECURITY POLICY FILTER PREDICATE fn(col) | FILTER = SELECT. BLOCK = DML. Inline TVF predicate is mandatory. |
| DDM | MASKED WITH (FUNCTION='default()') | DEFAULT/EMAIL/PARTIAL/CUSTOM. UNMASK permission bypasses. Not encryption — app-layer only. |
| Always Encrypted | CMK (stored in Key Vault) → CEK → Column | Deterministic = can filter/join. Randomized = more secure, no search. Driver-side encryption. |
| Column Encryption | ENCRYPTBYKEY / DECRYPTBYKEY | Symmetric key. Server-side. Weaker than Always Encrypted. |
| RLS Predicate | CREATE FUNCTION … RETURNS TABLE WITH (NOEXPAND) | Must use SCHEMABINDING. One policy per table max. |
| Passwordless | Managed Identity → Azure AD token | No password in connection string. System-assigned vs user-assigned MI. |
| Auditing | Server-level > DB-level. Destinations: Blob, Log Analytics, Event Hub. | Action groups: SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP etc. |
| Config Key | Purpose |
|---|---|
| rest.path | URL path override. Default = entity name. |
| graphql.type | GraphQL type name. Enables relationships. |
| permissions.role | anonymous | authenticated | custom role |
| source.type = stored-procedure | Expose SP as REST/GraphQL endpoint |
| cache.enabled = true | In-memory cache, TTL configurable |
| pagination.$limit | Max page size. Use $after cursor for keyset. |
| Method | Granularity | Best For | Overhead |
|---|---|---|---|
| Change Tracking | Row (changed/deleted flag) | Sync, lightweight embedding triggers | |
| CDC | Row + before/after column values | Audit, ETL, embedding pipelines | |
| CES | Real-time event stream | Streaming analytics, event-driven AI | |
| Az Functions SQL Trigger | Row-level, event-driven | Serverless embedding refresh on change | |
| Logic Apps | Connector-based polling | Low-code integration pipelines |
| Function | Purpose |
|---|---|
| VECTOR_DISTANCE(metric, v1, v2) | cosine | dot_product | euclidean |
| VECTOR_NORMALIZE(v) | Unit vector — required before dot product |
| VECTORPROPERTY(col, 'Dimensions') | Returns dimension count of a VECTOR column |
| VECTOR_SEARCH() | ANN top-K via index (DiskANN). Fast at scale. |
| Type | Mechanism | Use When |
|---|---|---|
| Full-Text | BM25 TF-IDF scoring. CONTAINS / FREETEXT / FREETEXTTABLE. Requires full-text index. | Keyword search, exact phrase matching, stemming |
| Semantic Vector | VECTOR_DISTANCE on embeddings. Meaning-based retrieval. | Conceptual match, multilingual, paraphrase detection |
| Hybrid Search | Full-text score + vector score merged via RRF. | Best of both — production RAG retrieval |
| Maintenance Method | Trade-off |
|---|---|
| AFTER INSERT/UPDATE Trigger | Synchronous — blocks write. Simple. Risk: trigger failure = write failure. |
| Change Tracking + batch job | Asynchronous — no write overhead. Slight lag. Good for bulk tables. |
| CDC + Azure Function | Event-driven. Near real-time. Serverless scale. Recommended for prod. |
| CES | Streaming. Lowest latency. Most complex to manage. |