Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

Data type between varchar and text

I have a table that currently has a text field I am trying to switch it to a different datatype, like varchar(8000). This worked great for most of my databases, unfortunately there are 4 out of 20 that seem to have more data than 8000 characters in that field so changing to varchar(8000) would truncate the data.

Is there a data type I can use that is NOT text and is more than 8000 characters?  I think 16000 would do, but varchar won't' support that many characters.

I won't get into why I don't want to use text, just gives me way too many issues.
SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aleks

ASKER

I have had the same issue with that data type. When I display the information on my ASP page nothing will show. So ... that may not work unfortunately. Ill try again but I remember clearly it was the same issue as text.
Avatar of Aleks

ASKER

I tried and I DID remember correctly, data is not displayed in my ASP page when using the above type.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>I tried and I DID remember correctly, data is not displayed in my ASP page when using the above type.<<
That is an ADO problem and nothing to do with SQL Server.  If you want to post your code (I am going to guess SELECT *)  and we can help you code it correctly in ASP.
Avatar of Aleks

ASKER

It actually does not have Select *

This is the query being run:

SELECT  a.COMID ,         a.CaseID ,         a.Visible ,         a.VisibleEmployer ,         a.Comments ,         a.Updatedby ,         a.Lastupdate ,         a.CommBy ,         a.SectionCase ,         b.MaidenNm ,         b.MailStr ,         a.Importance FROM    dbo.Casecomments a         LEFT JOIN Users AS b ON a.Updatedby = b.UserId WHERE  bla bla bla;" 

Open in new window

Avatar of Aleks

ASKER

I create the recordset using DWCS6.  The code is below.
When I used to have DW8 I was able to move the cursor to the client and then it would display the data from a text field. But CS6 doesn't have an option to change the cursor to client.

<%
Dim rs_notes__MMColParam
rs_notes__MMColParam = "0"
If (Request.Querystring("NewUserID") <> "") Then 
  rs_notes__MMColParam = Request.Querystring("NewUserID")
End If
%>
<%
Dim rs_notes__MMColParam2
rs_notes__MMColParam2 = "0"
If (Session("firmid") <> "") Then 
  rs_notes__MMColParam2 = Session("firmid")
End If
%>
<%
Dim rs_notes
Dim rs_notes_cmd
Dim rs_notes_numRows

Set rs_notes_cmd = Server.CreateObject ("ADODB.Command")
rs_notes_cmd.ActiveConnection = MM_bluedot_STRING
rs_notes_cmd.CommandText = "SELECT  a.COMID ,         a.CaseID ,         a.Visible ,         a.VisibleEmployer ,         a.Comments ,         a.Updatedby ,         a.Lastupdate ,         a.CommBy ,         a.SectionCase ,         b.MaidenNm ,         b.MailStr ,         a.Importance FROM    dbo.Casecomments a         LEFT JOIN Users AS b ON a.Updatedby = b.UserId WHERE   CaseID = ?         AND a.SectionCase = 'Alien'         AND a.FirmId = ? ORDER BY a.Lastupdate DESC;" 
rs_notes_cmd.Prepared = true
rs_notes_cmd.Parameters.Append rs_notes_cmd.CreateParameter("param1", 5, 1, -1, rs_notes__MMColParam) ' adDouble
rs_notes_cmd.Parameters.Append rs_notes_cmd.CreateParameter("param2", 5, 1, -1, rs_notes__MMColParam2) ' adDouble

Set rs_notes = rs_notes_cmd.Execute
rs_notes_numRows = 0
%>

Open in new window

Avatar of Aleks

ASKER

Is there anything between varchar(8000) and varchar(MAX) ?    this change would be easier than going over all the pages in the system that don't display a text field. Plus 90% of the times the entry is way smaller of 8000 characters and in our upgrade we limited the entry to 8000.  Only a few entries have about 10,000 characters and the conversion fails due to data being truncated. A field about 10 or 15000 characters should suffice.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aleks

ASKER

Will that work if there is more than one text field or will one of them have the issue ?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aleks

ASKER

Ill give it a try . If it works Ill award the points tomorrow. Thanks !
Avatar of Aleks

ASKER

I changed it to varchar(MAX) and changed the query to have the field at the end .. turns out it works, so Ill try that and see how it goes. Thanks !   If anything else comes up Ill open another ticket.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Text is a BLOB or Binary Large Object data type. It stores data, generally, not in the table, but rather in a space out on the file system.
No.  SQL Server's BLOB data types such as (n)varchar(MAX), varbinary(MAX) and Xml and the deprecated (n)text and image are not stored "in a space out on the file system"  I have no idea where you got this idea (unless you also consider the standard data types to also be stored "in a space out on the file system" simply because they are stored in data files).  The data for BLOB data types are stored in the database and by default in a special BLOB structure.  You may alternatively store the values in row using the "large value types out of row" option.