Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loose data in insert 1

Status
Not open for further replies.

JeanPhil

Programmer
Dec 23, 2003
27
CA
Hi ... I have a problem that I really don't understand !!!

I do a simple SQL INSERT Statement with .asp code into a SQL Server 2000 database and I loose data while it insert.

To be clearer, I have a note field (nvarchar with a lenght of 2000 characters). The problem is that it doesn't insert the whole text in the database. Usualy I get an error message like 'Data will be truncated' but I don't. I printed the SQL sentence and insert it directly with the query analyser and it still won't take all the text (which is about 200 characters). I really don't understand and would appreciate a lottle help !!
 
You may get better response if you post in the SQL Server: Programming forum. This question is not about the SQL standard.

That said, you may be experiencing a display limitation rather than a loss of data. I created a table, NoteThis, with a column, message, of the datatype NVARCHAR(2000). I inserted a row with 24x12=288 characters, then displayed the row with a SELECT statement in Query Analyzer. It shows (21x12)+4=256 characters. When I look at the row in Enterprise Manager I see all 288 characters. Or when I look for the last 12 characters using PATINDEX I find them.

Code:
SELECT * FROM NoteThis WHERE PATINDEX('%240123456789', message ) > 0

Could this be what you are seeing?
 
There is an option in query analyser to set the max result column length and it defaults to 256 chars.
I usually set this to 8000.

If that's not the problem then you will have to post the code and table structure.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top