Groups | Blog | Home
all groups > sql server msde > june 2005 >

sql server msde : Error message: String or binary data truncated


Lazar Videnov
6/23/2005 11:57:06 AM
Hi, all!

I encountered that error message while testing my application using
MSDE. It appears when I issue this type of statement:

INSERT INT atable (Col1, Col2, ...)
VALUES (Val1, Val2,...)

The string columns are of type 'char'.

The strange is that the message does not appear always. In one case I
had error in two consecutive executions of the query. After that, in the
3rd execution *with exactly the same data!* all went OK!? I cannot
understand where lies the problem.

The same thing does not happen at all when testing with MS SQL Server 2000.

Andrea Montanari
6/23/2005 12:20:08 PM
hi Lazar,
[quoted text, click to view]

are you sure this is not depending on the provided values exceeding the
maximum storage of the columns?
DECLARE @t TABLE (
c char(5)
)
INSERT INTO @t VALUES ( 'abcdefghi' )
--<------------
Server: Msg 8152, Level 16, State 9, Line 4
String or binary data would be truncated.
The statement has been terminated.

--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtm http://italy.mvps.org
DbaMgr2k ver 0.12.0 - DbaMgr ver 0.58.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
--------- remove DMO to reply

Lazar Videnov
6/23/2005 2:20:11 PM
Hi,

Actually, I don't do any checks for exceeding the storage space in the
string columns. I thought about that, but the strange is that this error
happens only sometimes. That is why I'm curious. And, as I wrote, it
works all fine in MS SQL Server 2000. I thought that the server just
trims the data and everything is OK.

Now, I'll make sure that I pass strings with length less than the
definition of the column, and I'll test again.

AddThis Social Bookmark Button