Skip to content

Latest commit

 

History

History
86 lines (63 loc) · 2.56 KB

File metadata and controls

86 lines (63 loc) · 2.56 KB
title AI_CLASSIFY (Transact-SQL)
description The AI_CLASSIFY function classifies input text into one of the provided labels.
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
sql-ai
f1_keywords
ai_classify_TSQL
ai_classify
helpviewer_keywords
ai_classify
dev_langs
TSQL
monikerRange =fabric

AI_CLASSIFY (Transact-SQL)

[!INCLUDE fabricsedw]

The AI_CLASSIFY function classifies input text into one of the labels you provide.

Note

Syntax

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

AI_CLASSIFY ( text, class1, class2 [ , ...n ] )

Arguments

text

An expression of a character type, for example nvarchar, varchar, nchar, or char.

class1, class2, ...n

One or more candidate class labels, provided as string literals or string expressions.

Return types

Returns nvarchar containing the selected class label.

Remarks

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.

Examples

A. Classify text with custom labels

SELECT ai_classify('Room was dirty', 'service', 'dirt', 'food') AS classification;

Expected result: dirt

B. Classify rows in a table

SELECT review_id,
       ai_classify(review_text, 'service', 'dirt', 'food', 'other') AS category
FROM dbo.hotel_reviews;

Related content