Lab 11: Implement RAG solutions: VECTOR_SEARCH T-SQL update required
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- sql
- Domain
- databases, documentation
Research direction
Start with the lab section “Retrieve data using vector search and format it as JSON context,” specifically Step 1 and its code window. Update the example to use the supplied VECTOR_SEARCH query without TOP_N, then verify the T-SQL remains valid and produces JSON context as described.
Written by the indexing model from the issue text.
Description
Section: Retrieve data using vector search and format it as JSON context
Step: 1
The code in this window needs to be updated. TOP_N function is not longer supported. It shoudl look something like this:
-- Convert a question to an embedding and find the closest matching reviews
DECLARE @userQuestion NVARCHAR(1000) =
N'What mountain bike can handle really technical rocky trails?';
DECLARE @questionVector VECTOR(1536);
-- Generate embedding for the question
SELECT @questionVector =
AI_GENERATE_EMBEDDINGS(
@userQuestion
USE MODEL my_embedding_model
);
-- Find the top 5 most relevant reviews using ANN vector search
SELECT TOP (5)
p.Name AS ProductName,
p.ListPrice,
pc.Name AS Category,
r.Rating,
r.ReviewTitle,
r.ReviewText,
vs.distance AS Distance
FROM VECTOR_SEARCH(
TABLE = dbo.ProductReview,
COLUMN = ReviewVector,
SIMILAR_TO = @questionVector,
METRIC = 'cosine'
) AS vs
INNER JOIN dbo.ProductReview AS r
ON r.ProductReviewID = vs.ProductReviewID
INNER JOIN SalesLT.Product AS p
ON r.ProductID = p.ProductID
INNER JOIN SalesLT.ProductCategory AS pc
ON p.ProductCategoryID = pc.ProductCategoryID
ORDER BY vs.distance
FOR JSON PATH;
GO
- Dominant language
- TSQL
- Stars
- 23
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MicrosoftLearning/mslearn-sql-developer
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
MicrosoftLearning/mslearn-sql-developer#12 · 2 comments ·
All issues in MicrosoftLearning/mslearn-sql-developer
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenLiberty/open-liberty#35839 ·
-
affects-9.0 found-by-ai may-affects-25.10 may-affects-26.3 may-affects-26.9 may-affects-7.5 may-affects-8.1 may-affects-8.5 severity/major sig/execution type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
antlr/grammars-v4#5014 · 1 comment ·