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

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s