Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

SQL Server - SQL field is defined as text

I have a question.  I'm working on a database and attempted to perform a DISTINCT and received an error.  After further investigation I found that the DISTINCT could not be performed because the field is defined as "text" and not "VARCHAR" or "NVARCHAR".

My understanding that "text" will be deprecated.

Can the field be easily updated with VARCHAR?
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Scott Pletcher
Try CASTing the text column(s) to varchar(max) or varchar(8000):

SELECT DISTINCT ..., CAST(text_column AS varchar(max)), ...
FROM ...
Avatar of CipherIS

ASKER

Yes, that is what I had to do.  I used CONVERT though.  I'm just analyzing the database.