The text, ntext, and image data > types cannot be compared or sorted, except when using IS NULL or LIKE > operator

since you are using SQL Server, why not change the data type to VARCHAR(100)?

To work around this error without changing the datatype, the TEXT or NTEXT column needs to be converted to VARCHAR or NVARCHAR when used in either the ORDER BY clause or the GROUP BY clause of a SELECT statement. eg, which is alittle bit messy

SELECT  CAST(email AS NVARCHAR(100)) email, 
        COUNT(CAST(email AS NVARCHAR(100))) AS NumOccurrences
FROM    Booking
GROUP   BY CAST(email AS NVARCHAR(100))
HAVING  COUNT(CAST(email AS NVARCHAR(100))) > 1 

Leave a Comment