| title | AI_ANALYZE_SENTIMENT (Transact-SQL) | ||
|---|---|---|---|
| description | The AI_ANALYZE_SENTIMENT function detects sentiment in input text. | ||
| author | WilliamDAssafMSFT | ||
| ms.author | wiassaf | ||
| ms.reviewer | jovanpop | ||
| ms.date | 06/10/2026 | ||
| ms.service | sql | ||
| ms.subservice | t-sql | ||
| ms.topic | reference | ||
| ms.custom |
|
||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
||
| monikerRange | =fabric |
[!INCLUDE fabricsedw]
The AI_ANALYZE_SENTIMENT function analyzes input text and returns one of these sentiment labels: positive, negative, mixed, or neutral.
Note
AI_ANALYZE_SENTIMENTis in preview.AI_ANALYZE_SENTIMENTis available only in [!INCLUDE fabric-se-short] and [!INCLUDE fabric-dw].
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
AI_ANALYZE_SENTIMENT ( text )
An expression of a character type, for example nvarchar, varchar, nchar, or char.
Returns nvarchar with one of the following values:
positivenegativemixedneutral
AI functions return NULL if the AI model can't process the text. Common reasons include:
- Responsible AI rules block inappropriate content in the input text.
- Input text exceeds token limits. The current model supports up to 15 KB of text.
SELECT ai_analyze_sentiment('This hotel was great!') AS sentiment;Expected result: positive
SELECT review_id,
ai_analyze_sentiment(review_text) AS sentiment
FROM dbo.hotel_reviews;