MSSQL query failing inside job
Posted on 2014-09-26
This is a little odd to me. I have an update query that I'm running in SSMS that works fine. But inside a job it fails.
String or binary data would be truncated. [SQLSTATE 22001] (Error 8152) The statement has been terminated. [SQLSTATE 01000] (Error 3621). The step failed.
SET emailAddress = ad.mail
FROM einfo e, ourdba.dbo.ourvw_adusers2 ad
WHERE ltrim(rtrim(e.id)) = ad.employeeid
AND ltrim(rtrim(e.emailaddress)) <> ad.mail
AND empStatus in ('A', 'L')
Basically it is taking the data in a view, created by pulling the data from active directory and creating the view. I have created the view using the following select:
SELECT cn, sAMAccountName, convert(varchar(50), mail) as mail, l, userPrincipalName, distinguishedname, convert(varchar(10),employeeid) as employeeid
The table being updated einfo has emailaddress VARCHAR(50) and employeeid VARCHAR(10).
Why is this failing during the job? The source VIEW and destination table EINFO should have the same size data?
Getting a little crazy with this.