AI_GENERATE_RESPONSE#
Generates text from a prompt. With one argument, the prompt itself is the per-row input; with two arguments, the first is the instruction and the second is the per-row data it is applied to.
Syntax#
AI_GENERATE_RESPONSE ( prompt [ , data ] )
Arguments#
prompt
The instruction for the model. Any character expression (char, varchar, nchar or nvarchar).
data
Optional per-row text the prompt is applied to.
Return types#
nvarchar(max)
Remarks#
The function executes in Querona against the session’s ambient AI model (see AI (generative)) and works over data from any connected source. A failed call — provider error, content restriction, or input over roughly 15 KB — returns NULL for that row without aborting the query; an authorization failure (for example a rejected API key) raises a statement-level error instead. The function is non-deterministic and is re-evaluated on every execution.
Example#
SELECT AI_GENERATE_RESPONSE('Reply professionally in 30 words:', review_text) AS reply
FROM hotel_reviews;