Short answer: an embedding is a list of numbers a model makes from a text (or an image) so that similar meanings get similar numbers. Vector search finds the rows whose embeddings are closest to a question's embedding. SQL Server 2025, Azure SQL Database, Azure SQL Managed Instance and SQL database in Fabric have a vector type and VECTOR_DISTANCE, so this runs in the database, next to the rows it describes.
Keyword search finds "bike" only where the word is. Vector search also finds "bicycle" and "e-bike", because their embeddings sit close together.
How does a search run?
- 1Question"waterproof jacket for cycling"
- 2Embeddingthe same model turns it into a vector
- 3Distanceto every product's stored vector
- 4Closest rowsthe products nearest in meaning
The products' embeddings are made once and stored in a column; only the question is embedded at search time. Both must come from the same model.
What does it look like in T-SQL?
ALTER TABLE dbo.Product ADD DescriptionVector vector(1536);
DECLARE @q vector(1536) = AI_GENERATE_EMBEDDINGS(N'waterproof jacket for cycling' USE MODEL MyEmbeddingModel);
SELECT TOP (10) ProductID, Name,
VECTOR_DISTANCE('cosine', @q, DescriptionVector) AS Distance
FROM dbo.Product
ORDER BY Distance;AI_GENERATE_EMBEDDINGS calls a model you registered in the database with CREATE EXTERNAL MODEL; you can also make the embeddings outside and store them. Vectors are stored compactly and shown as JSON arrays, so CAST('[0.1, -0.2, 0.3]' AS vector(3)) works too.
Exact search or a vector index?
| Way | How | When |
|---|---|---|
| Exact (kNN) | VECTOR_DISTANCE on every candidate row | up to about 50,000 vectors after other filters |
| Approximate (ANN) | a vector index (DiskANN) and VECTOR_SEARCH | far more vectors, when nearly exact is fine |
Start exact: it is always right, and a WHERE on category or date often brings the candidates under the limit. Add a vector index when the table outgrows it. The vector type and functions are generally available in all four products; vector indexes are generally available in Azure SQL Database and SQL database in Fabric, and in preview in SQL Server 2025.
What goes wrong?
- Two models. Embeddings from different models cannot be compared. Store the model's name with the vectors, and re-embed when you change it.
- Stale embeddings. When a description changes, its vector must too. Re-embed in the same step that updates the row, or from change tracking.
- Whole documents in one vector. A long text squeezed into one embedding blurs. Split it into chunks and embed each.
Where can you check this?
- Microsoft Learn: Vector search and vector indexes in the SQL Database Engine
- Microsoft Learn: Vector data type
- Microsoft Learn: VECTOR_DISTANCE (Transact-SQL)
Where do you start?
DP-800 in 2026 shows how vector search leads to answering questions from your own rows, and the open course Upserts into Azure SQL builds the kind of table you would add a vector column to.