473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SQL Server 2K truncating text fields at 255 chars

I'm running SQL Server 2K (sp3a) and when I run the following query (in
query analyzer):

SELECT id, LEN(ForeignWord) as Length, ForeignWord
FROM Words
WHERE Language ='Thai' and LEN(ForeignWord) > 300
ORDER BY Length desc

I receive the following results:

id Length ForeignWord
------- ----------- -----------
34756 445 เ&#35...truncated at 255
34839 412 เ&#36...truncated at 255
37613 350 โ&#35...truncated at 255
37808 315 โ&#35...truncated at 255
38140 315 โ&#35...truncated at 255

(The ForeignWord field is defined as varchar(1000))
Note that even though the server says that the lengths are in excess of
255 characters, the results are all truncated at 255 characters.

I read that SQL Server 6.5 and 7.0 had some issues related to native
access versus OleDb or ODBC, but this is Server 2K patched with the
latest updates.

Any idea why my varchar fields are being truncated?

-- Rick

Here is my table definition:

CREATE TABLE [Words] (
[ID] [bigint] IDENTITY (1, 1) NOT NULL ,
[Language] [varchar] (50) NOT NULL ,
[Module] [int] NOT NULL ,
[Lesson] [int] NOT NULL ,
[EnglishWord] [varchar] (1000) NOT NULL ,
[ForeignWord] [varchar] (1000) NOT NULL ,
[Note] [varchar] (2000) NULL ,
[Military] [tinyint] NOT NULL CONSTRAINT [DF_Table1_Military]
DEFAULT (0),
[Supplemental] [tinyint] NOT NULL CONSTRAINT [DF_Table1
_Supplemental] DEFAULT (0),
[SoundFileName] [varchar] (1000) NULL
)

Jul 20 '05 #1
4 13795


Guinness Mann wrote:
I'm running SQL Server 2K (sp3a) and when I run the following query (in
query analyzer):

SELECT id, LEN(ForeignWord) as Length, ForeignWord
FROM Words
WHERE Language ='Thai' and LEN(ForeignWord) > 300
ORDER BY Length desc
Try this:

SELECT id, LEN(ForeignWord) as Length, convert( text, ForeignWord)
FROM Words
WHERE Language ='Thai' and LEN(ForeignWord) > 300
ORDER BY Length desc


I receive the following results:

id Length ForeignWord
------- ----------- -----------
34756 445 เ&#35...truncated at 255
34839 412 เ&#36...truncated at 255
37613 350 โ&#35...truncated at 255
37808 315 โ&#35...truncated at 255
38140 315 โ&#35...truncated at 255

(The ForeignWord field is defined as varchar(1000))

Note that even though the server says that the lengths are in excess of
255 characters, the results are all truncated at 255 characters.

I read that SQL Server 6.5 and 7.0 had some issues related to native
access versus OleDb or ODBC, but this is Server 2K patched with the
latest updates.

Any idea why my varchar fields are being truncated?

-- Rick

Here is my table definition:

CREATE TABLE [Words] (
[ID] [bigint] IDENTITY (1, 1) NOT NULL ,
[Language] [varchar] (50) NOT NULL ,
[Module] [int] NOT NULL ,
[Lesson] [int] NOT NULL ,
[EnglishWord] [varchar] (1000) NOT NULL ,
[ForeignWord] [varchar] (1000) NOT NULL ,
[Note] [varchar] (2000) NULL ,
[Military] [tinyint] NOT NULL CONSTRAINT [DF_Table1_Military]
DEFAULT (0),
[Supplemental] [tinyint] NOT NULL CONSTRAINT [DF_Table1
_Supplemental] DEFAULT (0),
[SoundFileName] [varchar] (1000) NULL
)


Jul 20 '05 #2
Guinness Mann (GM***@dublin.com) writes:
I read that SQL Server 6.5 and 7.0 had some issues related to native
access versus OleDb or ODBC, but this is Server 2K patched with the
latest updates.

Any idea why my varchar fields are being truncated?


In Query Analyzer, Tools->Options->Results->Maximum character per column.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
In article <Xn**********************@127.0.0.1>, so****@algonet.se
says...
Any idea why my varchar fields are being truncated?


In Query Analyzer, Tools->Options->Results->Maximum character per column.


That's really funny. It absolutely was the solution for my truncation
in ISQL/W.

But the reason I was looking at the data in Query Analyzer was because
another developer, using PHP, was getting truncated results using
whatever data access method PHP users use.

So it was a coincidence that I saw the same symptoms they were seeing.

I wrote a .NET program in C# to retrieve the data and got full,
untruncated data.

I don't know why PHP truncates their data, but as far as I'm concerned,
it's not a SQL Server problem.

-- Rick

Jul 20 '05 #4
Guinness Mann (GM***@dublin.com) writes:
That's really funny. It absolutely was the solution for my truncation
in ISQL/W.

But the reason I was looking at the data in Query Analyzer was because
another developer, using PHP, was getting truncated results using
whatever data access method PHP users use.


I know very little about PHP. But I've PHP users who had had connection
problems and their error messages indicates that they are using
DB-Library. DB-Library is an abandoned client library, and does not
support varchar data > 255, so if you need that long data with PHP
library, you need to use the text data type.

Now, just like there is more than one way to connect to SQL Server from
Perl, there might be more than one way from PHP.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: James | last post by:
I am currently working on a PHP based website that needs to be able to draw from Oracle, MS SQL Server, MySQL and given time and demand other RDBMS. I took a lot of time and care creating a...
3
by: Fardude | last post by:
I have a few tables in SQL Server 2000 and a small Access 97 that has linked tables used to insert/update/delete into SQL Server 2k tables. Everything works fine except Updating one of these...
1
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
5
by: VM | last post by:
How can I truncate a string? For example, if I have a string containing "Hello All" but the space reserved for this string is of 4 chars, how can I truncate it to "Hell"? Would I need to create my...
17
by: tommy | last post by:
Hi all, I' m adding strings to some fields in my table via Access. The strings sometimes have trailing spaces and I really need to have it that way, but Access truncates trailing spaces. How can...
7
by: h7qvnk7q001 | last post by:
I'm trying to implement a simple server-side form validation (No Javascript). If the user submits a form with errors, I want to redisplay the same form with the errors highlighted. Once the form...
0
by: Rob van Dort | last post by:
I would like to have a piece of code (XSL, Java) with which I can truncate strong typed text fields in an XML documents according to length definitions in an XSD. Anybody seen such a piece of code...
0
by: hellosibba | last post by:
Hi i am trying to use text file to write a value as soon as there is any update/insert into a table. for that i am using a text file and made a linked server relation with it..... and inserting...
8
code green
by: code green | last post by:
I am using an ODBC connection to a MS Access database. When using a SELECT statement and collecting the data via php ODBC functions, I find that the data from TEXT fields is truncated to 255...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.