Vector search: VECTOR_SEARCH() with DiskANN index (cosine metric)
Critical Facts
PREVIEW_FEATURES = ON is REQUIRED — 01_schema.sql sets ALTER DATABASE SCOPED CONFIGURATION SET PREVIEW_FEATURES = ON; which is mandatory for CREATE VECTOR INDEX and VECTOR_SEARCH() in SQL Server 2025
Embedding model name MUST use -query suffix: nvidia/nv-embedqa-e5-v5-query. The -query suffix bakes in the input_type=query parameter server-side — AI_GENERATE_EMBEDDINGS cannot send input_type.
Vector dimensions are 1024 (not 1536)
sp_invoke_external_rest_endpoint max timeout is 120 seconds
NIM rejects application/json;charset=utf-8 — the NGINX annotation strips the charset suffix
Chat model (llama-3.2-3b) is small — system prompt MUST include grounding facts for quality answers
01_schema.sql runs against master (creates the database). All other scripts run against zavahospital.
Script 08 and 13 call NIM to generate embeddings — they take longer than other scripts
Post-filter compensation: VECTOR_SEARCH() applies JOINs/WHERE after the ANN scan, so procs over-fetch 3x
EXTERNAL MODEL fails → use API_FORMAT = 'OpenAI', URL must end in /v1/embeddings
NIM pod OOM → use llama-3.2-3b (not 8B) for chat on T4
Chat hallucinations → add grounding facts to system prompt (3B model needs explicit context)
02_seeding.sql "already seeded" → script has guard clause; drop+recreate via 01_schema.sql first
Script 08/13 slow → these call NIM for each row; normal for initial population
Demo Narrative
Edge AI pattern: hospital runs SQL Server 2025 + NIM on Azure Local in their data center. Patient data never leaves the building — zero cloud API calls. Same code, same containers, same T-SQL works in cloud AKS or on-premises Azure Local.
1---2name: microsoft-bobsql-bobsql3description: ZavaHospital – SQL Server 2025 + NVIDIA NIM on AKS4---56# ZavaHospital – SQL Server 2025 + NVIDIA NIM on AKS78## Architecture9- **SQL Server 2025** on localhost, Windows auth, database `zavahospital`10- **NVIDIA NIM embeddings**: `nvidia/nv-embedqa-e5-v5-query` (1024 dims, T4 GPU on AKS)11- **NVIDIA NIM chat**: `meta/llama-3.2-3b-instruct` (T4 GPU on AKS)12- **AKS cluster**: `aks-nvidianim` in `rg-nvidianim-westus2`, 2x NC4as_T4_v3 GPU nodes13- **TLS**: Self-signed cert (CN=nim-aks.local) via AKS Web App Routing (managed NGINX ingress)14- **Hostname**: `nim-aks.local` → `<aks-ingress-ip>` via hosts file15- **Content-Type fix**: NGINX annotation `proxy_set_header Content-Type "application/json"`1617## Flow18```19SQL Server 2025 → HTTPS → AKS Ingress (nim-aks.local) → NIM pods20```21- Embeddings: `AI_GENERATE_EMBEDDINGS(@prompt USE MODEL NIMEmbeddingModel)` → 1024-dim vector22- Chat: `sp_invoke_external_rest_endpoint` → `https://nim-aks.local/v1/chat/completions`23- Vector search: `VECTOR_SEARCH()` with DiskANN index (cosine metric)2425## Critical Facts26- **PREVIEW_FEATURES = ON** is REQUIRED — `01_schema.sql` sets `ALTER DATABASE SCOPED CONFIGURATION SET PREVIEW_FEATURES = ON;` which is mandatory for `CREATE VECTOR INDEX` and `VECTOR_SEARCH()` in SQL Server 202527- Embedding model name MUST use `-query` suffix: `nvidia/nv-embedqa-e5-v5-query`. The `-query` suffix bakes in the `input_type=query` parameter server-side — `AI_GENERATE_EMBEDDINGS` cannot send `input_type`.28- Vector dimensions are **1024** (not 1536)29- `sp_invoke_external_rest_endpoint` max timeout is **120 seconds**30- NIM rejects `application/json;charset=utf-8` — the NGINX annotation strips the charset suffix31- Chat model (llama-3.2-3b) is small — system prompt MUST include grounding facts for quality answers32- `01_schema.sql` runs against **master** (creates the database). All other scripts run against **zavahospital**.33- Script 08 and 13 call NIM to generate embeddings — they take longer than other scripts34- Post-filter compensation: `VECTOR_SEARCH()` applies JOINs/WHERE after the ANN scan, so procs over-fetch 3x3536## Database Design37- **Schemas**: `ref` (reference), `core` (patients/encounters), `clinical` (vitals/notes/orders/alerts), `sec` (RLS)38- **Ledger**: `clinical.DoctorNotes` uses `LEDGER = ON (APPEND_ONLY = ON)` for audit immutability39- **RLS**: Row-Level Security predicates scope data by building/ward via `SESSION_CONTEXT`40- **ADR**: `ACCELERATED_DATABASE_RECOVERY = ON`41- **Optimized Locking**: `OPTIMIZED_LOCKING = ON`42- **Data compression**: `clinical.VitalsSnapshots` uses `DATA_COMPRESSION = ROW`4344## Stored Procedures45| Proc | Purpose |46|------|---------|47| `clinical.usp_GetCurrentPatientVitals` | Latest vitals per patient (open encounters) |48| `clinical.usp_GetPatientSymptoms` | Symptoms for patient/encounter |49| `clinical.usp_GetDoctorNotes` | Doctor notes with filtering |50| `clinical.usp_CreateOrder` | Create clinical order |51| `clinical.usp_findsimilarcases` | Vector search for similar encounters (3x over-fetch) |52| `clinical.usp_clinical_recommendation` | RAG: vector search + NIM chat → structured JSON recommendation |53| `clinical.usp_search_doctor_notes` | Vector search on individual doctor notes |5455## Embedding Tables56| Table | Granularity | Source |57|-------|-------------|--------|58| `clinical.EncounterVectors` | One vector per encounter | Composite narrative (reason + symptoms + orders + vitals + notes + ward) |59| `clinical.DoctorNotesEmbeddings` | One vector per doctor note | Individual `NoteText` from `clinical.DoctorNotes` |6061## Script Execution Order62```powershell63# Against master (creates database):64sqlcmd -S localhost -d master -E -i 01_schema.sql6566# Against zavahospital (all remaining):67sqlcmd -S localhost -d zavahospital -E -i 02_seeding.sql68sqlcmd -S localhost -d zavahospital -E -i 03_procs.sql69sqlcmd -S localhost -d zavahospital -E -i 05_dbcreds.sql -v MasterKeyPassword="<your-strong-password>"70sqlcmd -S localhost -d zavahospital -E -i 06_ai_model.sql71sqlcmd -S localhost -d zavahospital -E -i 07_embedding_table.sql72sqlcmd -S localhost -d zavahospital -E -i 08_genembeddings.sql # calls NIM73sqlcmd -S localhost -d zavahospital -E -i 09_create_vector_index.sql74sqlcmd -S localhost -d zavahospital -E -i 10_find_similar_cases.sql75sqlcmd -S localhost -d zavahospital -E -i 11_clinical_recommendation.sql76sqlcmd -S localhost -d zavahospital -E -i 13_embeddingtable.sql # calls NIM77sqlcmd -S localhost -d zavahospital -E -i 14_create_notes_vector_index.sql78sqlcmd -S localhost -d zavahospital -E -i 15_search_doctor_notes.sql79```8081## Demo Scripts (run after deployment)82```powershell83sqlcmd -S localhost -d zavahospital -E -i 04_call_procs.sql84sqlcmd -S localhost -d zavahospital -E -i 12_call_recommendation.sql85sqlcmd -S localhost -d zavahospital -E -i 12_vector_search_exmple.sql86sqlcmd -S localhost -d zavahospital -E -i 16_call_search_doctor_notes.sql87```8889## Prerequisites (before running scripts)901. NIM on AKS deployed and pods running (see [nvidianim/SKILL.md](nvidianim/SKILL.md))912. Hosts file: `<aks-ingress-ip> nim-aks.local` (get the IP from `kubectl get ingress -n nim`)923. NIM TLS cert imported into Local Machine Trusted Root CAs934. SQL Server restarted after cert import945. `sp_invoke_external_rest_endpoint` enabled (`sp_configure`)956. Verify NIM endpoints respond: `.\test-embedding.ps1`, `.\test-chat.ps1` in [nvidianim/](nvidianim/)9697## Troubleshooting98- `AI_GENERATE_EMBEDDINGS` TLS error → import `nvidianim\k8s\tls.cer` to Trusted Root CAs, restart SQL99- Vector search returns fewer rows than expected → increase `@SearchTopN` (procs already over-fetch 3x)100- `nim-aks.local` unreachable → check hosts file, AKS ingress IP, pods running101- EXTERNAL MODEL fails → use `API_FORMAT = 'OpenAI'`, URL must end in `/v1/embeddings`102- NIM pod OOM → use llama-3.2-3b (not 8B) for chat on T4103- Chat hallucinations → add grounding facts to system prompt (3B model needs explicit context)104- `02_seeding.sql` "already seeded" → script has guard clause; drop+recreate via `01_schema.sql` first105- Script 08/13 slow → these call NIM for each row; normal for initial population106107## Demo Narrative108Edge AI pattern: hospital runs SQL Server 2025 + NIM on Azure Local in their data center. Patient data never leaves the building — zero cloud API calls. Same code, same containers, same T-SQL works in cloud AKS or on-premises Azure Local.109110---111> Source: [microsoft/bobsql](https://github.com/microsoft/bobsql) — distributed by [TomeVault](https://tomevault.io).112<!-- tomevault:4.0:skill_md:2026-06-21 -->
Run npx skillmds@latest add tomevault-io/microsoft-bobsql-bobsql in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
ZavaHospital – SQL Server 2025 + NVIDIA NIM on AKS It is listed under Data & Analytics on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.