Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 query error

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2004-10-26 : 03:08:45
I am doing a insert into table (select xx,ddd from table)

I get the following error:

Server: Msg 8152, Level 16, State 2, Line 1
String or binary data would be truncated.
The statement has been terminated.

Is there anyway of knowing which field is causing the error?

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2004-10-26 : 03:19:10
Please enumerate the insertion field and its datatype?

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2004-10-26 : 03:28:22
I think fields were all the same - But I still got an error.
I used SET ANSI_WARNINGS OFF and inserted them and so far records seem okay.
I don't care if I lost one field somewhere.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-10-26 : 03:49:57
One of the columns xx, ddd is wider than the corresponding column in the target table

When I have this problem with, say,

insert into TargetTable (select xx,ddd from SourceTable)

I do

select MAX(DATALENGTH(xx)) AS [LEN_XX],
MAX(DATALENGTH(ddd)) AS [LEN_DDD]
from SourceTable

to work out which one is too long, and then go from there

EDIT: But I agree - I too wish that SQL will tell me what the data was in the offending row

Kristen
Go to Top of Page
   

- Advertisement -