Hi @vissupangam-0394,
The problem is caused by the fact that SQL Server’s ntext, text, and image data types have been declared obsolete.
You can try to use the following code:
select distinct (CAST (id AS nvarchar(max))) from table_name
the permanent and suggested solution is to permanently change the data type of the column(s) using the obsolete data type(s) into their corresponding accepted data types:
ntext should become nvarchar(max)
text should become varchar(max)
image should become varbinary(max)
it can avoid losing valuable time with multiple CASTs and keep your query safe from performance issues.
https://learn.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15