AI_CLASSIFY#
Classifies the input text into exactly one of the supplied labels and returns the chosen label verbatim.
Syntax#
AI_CLASSIFY ( text_expression, label [ , ...n ] )
Arguments#
text_expression
The text to classify. Any character expression (char, varchar, nchar or nvarchar).
label [ , …n ]
One or more classification labels the model chooses from.
Return types#
nvarchar(max) — one of the supplied labels.
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 review_text,
AI_CLASSIFY(review_text, 'service', 'cleanliness', 'food') AS category
FROM hotel_reviews;