Okay, this is weird. I have a table with a lot of fields and 1 single record on which I'm having my "Data will be truncated" error. The single record has many NULL values and those fields that are not null add up to be approximately 465 characters. I'm using default SQL Server collation on 2005. The field having the truncation error (Comment) is Varchar(1500). The actual character length of the current value in the field is 138. So, I should have plenty of space in which to append another small character comment, right?
The above error is occurring on the Comment field, I've tested the code with variations to verify this. But the Comment field for this particular record has plenty of space in it...
Does anyone have any idea why this might be occurring? It's driving me nuts.
Thanks,
Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
Code:
Update t1
Set Status = 'A', ModifiedOn = GetDate(),
ModifiedBy = 'MyAuto-SQLJob',
Comment = ltrim(rtrim(isnull(t1.Comment,'')) + '. Status Modified per Ticketxxxxxx')
from table1 t1
left outer join table2 t2
on t1.PKID = t2.PKID
where t1.Status = 'R'
and t1.PKID not in (Select PKID from table2)
ERROR said:Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The above error is occurring on the Comment field, I've tested the code with variations to verify this. But the Comment field for this particular record has plenty of space in it...
Does anyone have any idea why this might be occurring? It's driving me nuts.
Thanks,
Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"