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.uniquestr
varchar(11)
table2.uniquestr
varchar(20)
table2
has records havinguniquestr
values of 11 characters , 15 characters.- the clause of query written in such way
select
statement never return records havinguniquestr
length 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