1. A team is building a RAG solution in Azure SQL Database. After retrieving relevant chunks via vector search, they need to pass the structured relational data to an Azure OpenAI model as context. How should the developer format the retrieved rows before including them in the prompt payload sent via sp_invoke_external_rest_endpoint?
- A. Serialize the rows as CSV text using BCP format directives
- B. Convert the rows to JSON using FOR JSON PATH or FOR JSON AUTO✓ Correct
- C. Pass the rows as a binary VARBINARY stream
- D. Export the rows to an Azure Blob Storage parquet file and reference the URL
Explanation
Azure OpenAI models expect text-based context in the prompt. The idiomatic T-SQL approach is to use FOR JSON PATH or FOR JSON AUTO to serialize relational result sets into JSON strings, which can then be embedded directly in the JSON request body constructed for sp_invoke_external_rest_endpoint. CSV via BCP format directives is not a native T-SQL serialization method and would require external tooling; moreover, LLMs process JSON-structured context far more reliably than raw CSV. A VARBINARY binary stream is a raw binary format that cannot be embedded in a JSON text payload and is not interpretable by the language model. Exporting to Azure Blob Storage parquet adds unnecessary latency, requires external storage access, and the model cannot read parquet files directly — it needs text in the prompt.