
Introduction
Imagine a customer searches an online shopping website for:
“Comfortable shoes for walking long distances.”
The product database contains these descriptions:
- Running shoes with extra cushioning
- Lightweight sports shoes
- Formal leather shoes
- Walking shoes with memory foam
- Hiking shoes with strong grip
A traditional SQL search can find products containing words such as walking or shoes. But what if a product description says “designed for all-day comfort” and never uses the word walking?
This is where vector search becomes interesting.
Traditional SQL search looks for matching values and words. Vector search looks for similarity in meaning using numerical representations called vectors, commonly generated by AI embedding models.
Let’s understand both approaches with practical examples.
1. What is Traditional SQL Search?
Traditional SQL search works with the actual values stored in database columns.
For example, suppose we have a Products table:
| ProductID | ProductName | Description |
|---|---|---|
| 1 | Running Shoes | Shoes with extra cushioning |
| 2 | Sports Shoes | Lightweight shoes for daily use |
| 3 | Formal Shoes | Leather shoes for office use |
| 4 | Walking Shoes | Comfortable shoes for walking |
| 5 | Hiking Shoes | Shoes with strong grip for hiking |
If a customer searches for the word walking, we can use the LIKE operator.
Example: Using LIKE
SELECT
ProductID,
ProductName,
Description
FROM dbo.Products
WHERE Description LIKE '%walking%';
This query returns products whose descriptions contain the word walking.
But there is a limitation.
What happens if a product description is:
“Lightweight footwear designed to keep your feet comfortable throughout the day.”
A customer searching for “walking shoes” might consider this product relevant, but the query may not return it because the description does not contain the word walking.
Traditional SQL search does not automatically understand that comfortable footwear and walking shoes may have related meanings.
What about SQL Server Full-Text Search?
SQL Server also provides Full-Text Search, which is more advanced than a simple LIKE search.
It supports word-based searching, including linguistic processing and word forms, and can rank results based on how well they match the search terms.
For example:
SELECT
ProductID,
ProductName,
Description
FROM dbo.Products
WHERE CONTAINS(Description, 'walking OR comfortable');
Full-Text Search is useful when you want to search for words, phrases and linguistic variations.
However, it is still based on language and terms, not the deeper semantic similarity provided by AI embeddings.
2. What is Vector Search?
Vector search works differently.
Instead of directly comparing words, it compares numerical representations of content.
These numerical representations are called embeddings.
An embedding model converts text into a list of numbers that represents information about its meaning and context.
For example, consider these three descriptions:
- “Comfortable shoes for walking long distances.”
- “Footwear designed for all-day comfort.”
- “Leather shoes for office meetings.”
An embedding model converts each description into a vector.
For illustration only:
| Description | Example vector |
|---|---|
| Comfortable shoes for walking | [0.21, 0.84, 0.32, 0.65] |
| Footwear for all-day comfort | [0.23, 0.81, 0.35, 0.62] |
| Leather shoes for office | [0.89, 0.12, 0.73, 0.18] |
These are simplified example values, not actual embeddings from an AI model.
The first two vectors are closer to each other than the third. This suggests that their descriptions have more semantic similarity.
When a customer searches for “comfortable shoes for walking long distances”, the search system generates an embedding for the query and compares it with the stored product embeddings.
It then returns the closest matches.
In simple words:
- Traditional SQL search asks: “Does this record contain the word I am searching for?”
- Vector search asks: “Which records have content similar in meaning to what I am searching for?”
3. How Does VECTOR_SEARCH Work in SQL Server?
SQL Server 2025 introduces the VECTOR data type and the VECTOR_SEARCH function.
The basic workflow looks like this:
- Store your product descriptions in SQL Server.
- Generate embeddings using an embedding model.
- Store those embeddings in a
VECTORcolumn. - Convert the customer’s search text into a query vector using the same compatible embedding model.
- Use
VECTOR_SEARCHto find similar vectors. - Return the matching product information.
For example:
Customer searches: “Comfortable shoes for long walks”
|
Embedding model converts the query into a vector
|
SQL Server compares it with stored product vectors
|
VECTOR_SEARCH calculates similarity distance
|
Returns the closest matching products
The important point is that SQL Server does not automatically understand the meaning of your product descriptions just because you created a VECTOR column.
You must generate and store meaningful embeddings first.
4. Practical Example: Traditional SQL Search vs VECTOR_SEARCH
Let’s compare both approaches using a product catalogue.
Approach 1: Traditional SQL Search
A customer searches for:
“Comfortable shoes for walking long distances.”
We can write:
SELECT
ProductID,
ProductName,
Description
FROM dbo.Products
WHERE Description LIKE '%walking%'
OR Description LIKE '%comfortable%';
This query looks for the specified words in the description.
It may return relevant products containing those words, but it can miss products that express the same idea differently.
For example:
“Lightweight footwear with extra cushioning for everyday use.”
The description may be relevant to the customer’s requirement, but it does not contain either search term.
Approach 2: Vector Search
Now let’s assume we have added an embedding column to our Products table.
CREATE TABLE dbo.Products
(
ProductID INT PRIMARY KEY,
ProductName NVARCHAR(200),
Description NVARCHAR(MAX),
ProductEmbedding VECTOR(1536)
);
Here:
ProductIDstores the product identifier.ProductNamestores the product name.Descriptionstores the product details.ProductEmbeddingstores the numerical representation of the description.
The dimension 1536 is an example. It must match the output dimension of the embedding model you use.
Assume the product descriptions already have embeddings and the customer’s search text has been converted into a compatible vector.
We can now use VECTOR_SEARCH:
DECLARE @QueryVector VECTOR(1536) =
'[0.21, 0.84, 0.32, 0.65]'; -- Illustrative only
The four values above are only illustrative. This variable is not a valid substitute for a real 1536-dimensional embedding.
For a real implementation, use the complete vector generated by your embedding model.
SELECT TOP (5) WITH APPROXIMATE
p.ProductID,
p.ProductName,
p.Description,
r.distance
FROM VECTOR_SEARCH
(
TABLE = dbo.Products AS p,
COLUMN = ProductEmbedding,
SIMILAR_TO = @QueryVector,
METRIC = 'cosine'
) AS r
ORDER BY r.distance;
This example uses the latest vector-index query syntax.
The query:
- Takes the customer’s query vector.
- Compares it with the stored product embeddings.
- Uses cosine distance to measure similarity.
- Returns up to five approximate nearest matches.
Important: A lower distance indicates a closer match. The distance is not a percentage or a direct confidence score.
Also, the query assumes that the table has been populated with real, compatible embeddings and that the required vector index is available.
5. What is a Vector Index, and Why Do We Need It?
Imagine you have 10 million products, and every product has an embedding.
If SQL Server has to calculate the distance between the query vector and every stored vector, searching can become expensive.
This is where a vector index helps.
A vector index is designed to improve nearest-neighbour searches by helping SQL Server locate vectors that are close to the query vector without necessarily comparing every row.
SQL Server supports vector indexes using the DiskANN approach.
For example:
CREATE VECTOR INDEX IX_Products_Embedding
ON dbo.Products(ProductEmbedding)
WITH
(
METRIC = 'cosine',
TYPE = 'diskann'
);
This creates a vector index using cosine distance.
The index and query syntax must be compatible with the vector index version and SQL Server environment.
Practical note: The latest vector index implementation has a minimum requirement of 100 rows before index creation. For a small table, you can also perform vector search without an index, but it uses a scan-based nearest-neighbour approach.
6. Traditional SQL Search vs VECTOR_SEARCH: Key Differences
| Feature | Traditional SQL Search | VECTOR_SEARCH |
|---|---|---|
| Search approach | Matches values or words | Finds similar vectors |
| Understands meaning | No semantic understanding by itself | Finds semantic similarity through embeddings |
| Search input | Text, numbers, conditions | Query vector |
| Common operators | =, LIKE, IN, CONTAINS | VECTOR_SEARCH |
| Indexing | B-tree or Full-Text indexes, depending on search | Vector index |
| Best suited for | Exact values, keywords, structured filters | Semantic and similarity search |
| Example | Find products containing “walking” | Find products similar in meaning to “shoes for long walks” |
| Result ranking | Based on query conditions or text relevance | Based on vector distance |
One important distinction: SQL Server Full-Text Search is more sophisticated than a simple LIKE search. It supports linguistic and relevance-based searching, but it is not the same as embedding-based semantic search.
7. Real-World Use Cases of Vector Search
Vector search is useful in applications where users describe what they need rather than knowing the exact words stored in the database.
Use Case 1: E-commerce Product Recommendations
A customer searches:
“Affordable laptop for programming and software development.”
The product catalogue may contain:
- Laptop with 16 GB RAM and SSD
- Developer laptop with a powerful processor
- Business laptop suitable for coding
- Gaming laptop with high processing power
Vector search can help identify products that are semantically related to the customer’s requirement, even when the descriptions use different words.
Traditional SQL filters can still be used for exact requirements such as price, RAM and brand.
Use Case 2: Customer Support Knowledge Base
Imagine a customer raises a support request:
“My application becomes very slow when many users access it.”
Your support database contains previous tickets such as:
- High CPU utilization during peak hours
- Application response time increases under heavy load
- Database connection pool exhaustion
- Slow queries during concurrent transactions
A keyword search may miss some relevant tickets because the wording is different.
Vector search can help identify previously resolved issues with similar meaning.
This can help support engineers find useful troubleshooting information faster.
Use Case 3: SQL Server DBA Troubleshooting
Consider a DBA investigating this issue:
“SQL Server queries are taking longer than usual.”
Your knowledge base contains articles and troubleshooting notes about:
- High CPU utilization
- Blocking and deadlocks
- Memory grant pressure
- Parameter sniffing
- Missing indexes
- TempDB contention
- Storage latency
A vector-based search can help find related troubleshooting material even if the exact words in the user’s question do not appear in the document.
For example, a search for “database is responding slowly” may find information about high CPU, blocking and query performance.
This is a useful potential application of vector search in an AI-powered DBA assistant.
However, vector search identifies relevant information; it does not automatically diagnose the root cause or fix the SQL Server problem.
8. Can We Combine Traditional SQL Search and VECTOR_SEARCH?
Absolutely. In many real-world applications, combining both approaches is more useful than choosing only one.
This is commonly called hybrid search.
Consider an online shopping application.
A customer searches:
“Comfortable shoes for long walks under ₹5,000.”
We have two different requirements:
- Find products semantically similar to comfortable shoes for long walks.
- Return only products priced below ₹5,000.
Vector search can identify semantically similar products, while traditional SQL conditions can enforce the price requirement.
For example:
SELECT TOP (10) WITH APPROXIMATE
p.ProductID,
p.ProductName,
p.Price,
r.distance
FROM VECTOR_SEARCH
(
TABLE = dbo.Products AS p,
COLUMN = ProductEmbedding,
SIMILAR_TO = @QueryVector,
METRIC = 'cosine'
) AS r
WHERE p.Price < 5000
AND p.IsActive = 1
ORDER BY r.distance;
This example uses the latest vector index syntax, where supported filters are applied during the vector search process.
For earlier vector index versions, filtering behaviour differs: filters can be applied after the nearest vectors have been retrieved. This can affect the number of qualifying results.
This is why understanding your vector index version is important.
Think of it this way:
- Vector search finds products that match the customer’s intent.
- SQL filters enforce business rules.
- SQL joins retrieve related information.
- SQL sorting and aggregation support reporting and analysis.
Together, these capabilities provide a more flexible search experience.
9. When Should You Use Traditional SQL Search and When Should You Use VECTOR_SEARCH?
You do not need vector search for every database query.
Choose the technology based on the problem you are trying to solve.
| Requirement | Recommended approach |
|---|---|
| Find an employee by EmployeeID | Traditional SQL |
| Find orders placed on a specific date | Traditional SQL |
| Search products containing a specific word | LIKE or Full-Text Search |
| Find documents similar in meaning | Vector search |
| Find support tickets related to a problem | Vector search |
| Find products matching a natural-language description | Vector search |
| Find semantically similar products under a specific price | Hybrid search |
| Search exact customer names or account numbers | Traditional SQL |
A good database design uses the right search approach for each requirement.
10. Important Considerations Before Implementing VECTOR_SEARCH
Before introducing vector search into a production environment, consider the following points.
1. Embedding quality matters
Your search quality depends heavily on the embedding model and the quality of the source content.
Poor descriptions or unsuitable embeddings can produce poor search results.
2. Use a compatible embedding model
Generate document and query embeddings using the same compatible model and vector dimensions.
3. Choose the right distance metric
SQL Server supports cosine, dot product and Euclidean distance. Select a metric appropriate for your embedding model and application.
4. Consider vector index requirements
Vector indexing improves approximate nearest-neighbour searches, but index creation has requirements and version-specific behaviour. Test with realistic data volumes and workloads.
5. Protect your data
Embeddings are derived from your source data. Apply appropriate security, access controls and data governance to both the original content and its embeddings.
6. Validate search quality
Test real user queries and review whether the returned results are genuinely relevant. Do not assume that a smaller distance always means a better business result.
11. SQL Server Version and Feature Availability
This is particularly important for DBAs and developers planning an implementation.
- SQL Server 2025 (17.x): The
VECTORdata type is available. Vector indexes andVECTOR_SEARCHare preview features and requirePREVIEW_FEATURES = ON. - Azure SQL Database: Vector indexes and
VECTOR_SEARCHare generally available. - Azure SQL Managed Instance: Availability depends on the update policy. They are generally available with the Always-up-to-date policy and preview with the SQL Server 2025 update policy.
- SQL database in Microsoft Fabric: Vector indexes and
VECTOR_SEARCHare generally available.
For SQL Server 2025, the preview configuration can be enabled at database scope:
ALTER DATABASE SCOPED CONFIGURATION
SET PREVIEW_FEATURES = ON;
Check the latest Microsoft documentation before implementing these features, as availability, syntax and limitations can change.
Summary
Traditional SQL search and vector search solve different problems.
Traditional SQL search is excellent when you know what you are looking for: a customer ID, product name, date, status or specific keyword.
Vector search becomes useful when you want to find information based on meaning rather than exact words.
For example, a customer may search for “comfortable shoes for long walks”, while the product description says “lightweight footwear with extra cushioning”.
Traditional keyword search may miss that connection. Vector search can help identify it through semantic similarity.
For database professionals, the important takeaway is that vector search does not replace relational database capabilities. It adds another way to search and retrieve information.
The future is not Traditional SQL Search vs Vector Search. It is knowing when to use each and how to combine them effectively.
Official Microsoft References
Technical note: The VECTOR_SEARCH example uses the latest vector index query syntax documented by Microsoft. Earlier vector index versions use a different syntax. Verify feature availability and preview requirements for your target SQL Server or Azure SQL environment before running the examples.
Discover more from Technology with Vivek Johari
Subscribe to get the latest posts sent to your email.



