AI_FIX_GRAMMAR#
Corrects the spelling, grammar and punctuation of the input text and returns the corrected text.
Syntax#
AI_FIX_GRAMMAR ( text_expression )
Arguments#
text_expression
The text to correct. Any character expression (char, varchar, nchar or nvarchar).
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#
NULL-on-failure never clobbers the original value when materializing:
UPDATE hotel_reviews
SET review_text = ISNULL(AI_FIX_GRAMMAR(review_text), review_text);