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.

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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -