Solved

Varchar(Max) problems

Posted on 2007-03-26
4
3,052 Views
Last Modified: 2012-06-27
Hello,

I am just embarking on a new project, and we have hit a scenario where we need to store more than 8000 characters in the field. Since we have upgradede to SQL 2005 it seems like the ideal opportunity to use VarChar(MAX).

However, i have read a couple of articles on the web saying that Classic ASP cannot handlle any string longer than 8000 characters and so therefore cannot read a string passed from the database if it exceeds this length. Is this true?

Whilst on the subject, in ASP i would setup my output parameters like so

.Parameters.Append .CreateParameter("@chvBody", adVarChar, adParamOutput, 1000)

However, with a MAX field i dont know the length of the output so, do i still declare the datatype as adVarChar, and what do i put as the length?

Thanks in advance

Al
0
Comment
Question by:higgsy
4 Comments
 
LVL 8

Accepted Solution

by:
drydenhogg earned 500 total points
ID: 18793347
You will have a dependency to SQL Native Client for this, VarChar(Max) has native client support, MDAC will not support it. So if your classic ASP can not gone up to SNAC then you do have a problem. When MDAC looks at a SQL 2005 VarChar(Max) it see's a text data type.

You will need to use the adLongVarChar types that used to be used for text, they handle the varchar(max) now within ADO. I have not seen the value you would use for the parameter length, in theory 2,147,483,647 is the max length of it (2^32 -1)

http://msdn2.microsoft.com/en-us/library/ms130978.aspx

hth
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18793542
>>what do i put as the length?

CLng(Len(your_actual_fields))

>>variables in Classic ASP are of type variant so a string variant can hold a variable-length string that can be up to approximately 2 billion characters in length. (from the VBScript / ASP documentation)

0
 
LVL 9

Expert Comment

by:fuzzboxer
ID: 18819887
You could try using the "text" data type.  It has a max length of 2^31.  That would be over 2 million.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18820142
>>You could try using the "text" data type. <<
The text data type is a deprecated data type, the questioner is better off using varchar(MAX)
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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