How long does an nvarchar field need to be before it is better to use a text field in SQL Server? What are the general indications for using one or the other for textual content that may or may not be queried?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From what I understand, the
TEXTdatatype should never be used in SQL 2005+. You should start usingVARCHAR(MAX)instead.See this question about
VARCHAR(MAX)vs.TEXT.UPDATE (per comment):
This blog does a good job at explaining the advantages. Taken from it:
So basically,
VARCHAR(MAX)keeps the data with the record, and gives you the ability to treat it like otherVARCHARtypes, like usingGROUP BYand string functions (LEN,CHARINDEX, etc.).For
TEXT, you almost always have to convert it toVARCHARto use functions against it.But back to the root of your question regarding efficiency, I don’t think it’s ever more efficient to use
TEXTvs.VARCHAR(MAX). Looking at this MSDN article (search for "data types"),TEXTis deprecated, and should be replaced with VARCHAR(MAX).