Link to home
Start Free TrialLog in
Avatar of fullmf
fullmf

asked on

String Truncation in a NVARCHAR field

Hi,

one of my fields in my database tables is of the data type NVARCHAR(4000).
I assign this field to be of the maximum length as I need to store text strings of various lengths
and some of these strings may contain characters like an 'e' with a stroke above (I do not know what you call that
in English).

I imported some data into the table and for the field of data type NVARCHAR(4000), the text information was
truncated at the 1000th character (inclusive of spaces). When I tried to enter some data directly into the field
using Enterprise Manager, I am unable to do so.

I hope someone can shed some light on this issue.

Regards,
CW
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

I think that's a limit of Enterprise manager.  I've had issues wiith it as well.  If you write a insert or update query in Query Analyzer, you can store more than 1000 characters.
Let us know whats the error it is throwing.

As such there is no limit in inserting data in Enterprise Manager,
Limitation is totaly depend on size and type of Field.

Also is it possible any other person is accessing the same field(Might be there is an lok on the table).

Amit
There may not technically be a limit, but I've encountered the same error in Enterprise Manager and inserted my data without issue using Query Analyzer.
Avatar of StephenCairns
StephenCairns

I've run into this same error. what version of SQL are you using?
I belive (and I cant remember where I found this) but there is a character max for a record in sqlserver2000. and its about 4000 chars
how many other characters are you inserting into the record?

possibly you could a different datatype??? or seperate table?

when I hit this problem we pushed it back to the users - if they want to write essays do it in word and attach the document

I guess this wont be much help

cheers
Two separate issues:

1.  Depending on the service pack there is a limit as to how many characters can be input in Enterprise Manager.  SP4 is 900 characters and SP3 is 1023.  Solution: Wean yourself from Enterprise Manager and use SQL Query Analyzer.

2. Unless you are using a double-byte language (such as Chinese) change nvarchar to varchar and you can then use up to 8000 bytes.  If you need more you may need to resort to text data type, but understand that there are limitations in functionality if you do that.
Agree with Acperkins--Enterprise manager was never meant to be used for a data entry tool...
acperkins, arbert are you talking about Enterprise manager or SQL Query analyzer?
I had this issue before (asp calling a stored proc), had the same issue calling the proc from the analyzer (or possibly the sql, it was a while ago)
oops just realised I said I found a  4000 char limit  I meant a 8000 char limit (4000 nvarchar)

I'm hoping I'm wrong
Cheers

>>acperkins, arbert are you talking about Enterprise manager or SQL Query analyzer?<<
I suspect if you re-read what we both said, the answer to that will become obvious.

If not, you should know that the data type length limit has nothing to do with the interface you are using, be it SQL Server Query Analyzer, Enterprise Manager, ADO, etc.
>>I suspect if you re-read what we both said, the answer to that will become obvious.<<
appologies, it is very obvious and i did miss it.

>>I imported some data into the table and for the field of data type NVARCHAR(4000), the text information was
truncated at the 1000th character (inclusive of spaces). When I tried to enter some data directly into the field
using Enterprise Manager, I am unable to do so.<<

When you imported what did you use?
I think possibly changing the datatype to text is worth a try.

cheers

where is the auther........

there is no comments from auther.....whats the actual requirement of auther.

Avatar of fullmf

ASKER

Hi, I took some time to digest all the comments from you helpful souls
and try out the suggestions.

For starters,
I am using MS SQL Enterprise Edition with SP4 Updates installed.

I am using a program that was developed in-house to import a text file into the database.
I guess I should use DTS instead in order to rule out any possibility that the error is caused by the program.

I am using only English language but the accented characters are missing if the field is VARCHAR, they are imported properly
when the field is NVARCHAR.

The length of the characters vary from anyway to a few hundered characters to a 2,500 characters.
In the meantime, I am going to try importing the text file again using DTS and give the feedback later.

Thank you for responding to my query.

Regards,
CW

>>I am using only English language but the accented characters are missing if the field is VARCHAR, they are imported properly
when the field is NVARCHAR.<<
If you are talking about the accented characters, characters with a tilde on top, etc  you have in some Latin languages such as: á, é, í, ó, ú, ü, ç, ñ, etc.  You do NOT need to use NVarchar.
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America 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