QuestionQ48

VerifiedImplement AI capabilities in database solutions

You have an Azure SQL Database that contains a table named dbo.ManualChunks. dbo.ManualChunks contains product manuals.

A retrieval query already returns the top five matching chunks as nvarchar(max) text. You need to call an Azure OpenAI REST endpoint for chat completions. The request body must contain both the user question and the retrieved chunks.

You write the following Transact-SQL code.

Question Image

What should you insert at line 22?

Explanation

FOR JSON PATH, WITHOUT_ARRAY_WRAPPER serializes the outer SELECT as one JSON object for the chat-completions request body. FOR JSON PATH maps the messages[0] and messages[1] aliases to nested JSON properties, and WITHOUT_ARRAY_WRAPPER prevents a top-level array. JSON_QUERY(@chunks) preserves the retrieved chunks as an embedded JSON fragment rather than escaped text.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!