Solved

in MSSQL what data type should I use for long strings

Posted on 2010-09-16
6
335 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
In this article I will describe the Backup & Restore 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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

856 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