Solved

in MSSQL what data type should I use for long strings

Posted on 2010-09-16
6
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

752 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