SQL server error - string or binary data would be truncated - even though SELECT statement returns nothing -
i have written query in stoted procedure, like,
insert table1 (uniquestr, col1, col2) select uniquestr, col1, col2 table2 ... it gives me error:
string or binary data truncated.
here statistics.
table1.uniquestrvarchar(11)table2.uniquestrvarchar(20)table2has records havinguniquestrvalues of 11 characters , 15 characters.- the clause of query written in such way
selectstatement never return records havinguniquestrlength greater 11.
the first weird scenario - though select statement returns nothing (when run separately), gives truncation error when run along insert (i.e. insert...select).
second weird scenario - gives error in production environment. gave no error in uat environment. in production environment, ran fine 1 day.
can tell me issue?
note: fixed error using substring function not find out reason why sql server gives error?
Comments
Post a Comment