Solved

Varchar(Max) problems

Posted on 2007-03-26
4
3,018 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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Comment Utility
>>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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now