Solved

in MSSQL what data type should I use for long strings

Posted on 2010-09-16
6
340 Views
Last Modified: 2012-05-10
I am storing some large strings in my MS SQL server. I want to use TEXT as the data type but am told that this will become obsolete in later versions of MSSQL server so I shouldn't use it. They say I should use NVarchar , but the max characters is 4,000, I need more than 4,000 characters in my strings. Is there a data type I can use for very large strings?

Thanks
0
Comment
Question by:elliottbenzle
6 Comments
 
LVL 9

Expert Comment

by:valkyrie_nc
ID: 33693643
You want varchar(MAX) or nvarchar(MAX); they store up to 2G data, which should hold whatever you need to put in the fields.

hth

valkyrie_nc
0
 
LVL 4

Author Comment

by:elliottbenzle
ID: 33693769
I tried to enter varchar(max) but get the error:

"Setting for Length must be from 1 to 8000."

leading me to believe that the maximum number of characters is 8000, which is less than I need.
0
 

Expert Comment

by:aryef
ID: 33693782
according to me experience, varchar(max) stores 4000 characters, while nvarchar(max) stores 2000 unicode characters.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 9

Expert Comment

by:valkyrie_nc
ID: 33693869
what version of SQL server are you using?  Varchar(MAX) is new to 2005, but the error you're showing seems to be 2000.
0
 

Expert Comment

by:aryef
ID: 33693929
when we nneded to store more that the max value, whatever it is, we split the string into a number of nvarchar(max)  fields. In practice, 4 to 6 such fields was enough  to store whatever we needed.
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 total points
ID: 33697047
In SQL 2000, you will be forced to use TEXT if it exceeds 8000 chars.

In SQL 2005, you can use varchar(MAX).

That error message doesn't look exactly like a SQL 2000 msg when you specify MAX.  What software is that msg coming from?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question