Technical: Microsoft – SQLServer – Error – “The conversion of the varchar value ‘100000’ overflowed an INT2 column. Use a larger integer column” (Msg 244, Level 16, State 2, Line 355)

Technical: Microsoft – SQLServer – Error – “The conversion of the varchar value ‘100000’ overflowed an INT2 column. Use a larger integer column” (Msg 244, Level 16, State 2, Line 355)



Msg 244, Level 16, State 2, Line 355

The conversion of the varchar value '100000' overflowed an INT2 column. 
Use a larger integer column  

Failing Code



    SELECT *
    FROM [dbo].[sales] tblSource

	inner join dbo.Worker tblWorker
	    on  (tblSource.salesPersonID = tblWorker.EmployeeID)

Corrected Code



    SELECT *
    FROM [dbo].[sales] tblSource

	inner join dbo.Worker tblWorker

           on   (isNumeric(tblWorker.EmployeeID) = 1)
	   and  (cast(tblSource.salesPersonID as int) = tblWorker.EmployeeID)

Explanation

  • Added isNumeric check to make sure employeeID is numeric
  • Cast salesPersonID as an int