• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3490
  • Last Modified:

The conversion of the varchar value '581123037000' overflowed an int column.

Trying to insert data in a temp table in memory for further work. I get the following error. I tried with and without cast and the same error in both cases. Please advice correction.
Msg 248, Level 16, State 1, Line 3
The conversion of the varchar value '581123037000' overflowed an int column.
The statement has been terminated.
drop table #TempPX
--charts by keyword
Select OCR.medrecactkey, OCR.addrkey, 
ME.MemberId, Cast(LDI.PRVID as bigint) as FacilityID, 
LG.LocationGroupId, HPE.DataCollectEndDate, LDI.POS
FROM odischartresolution OCR
JOIN table1 OA ON OCR.addrkey = OA.addrkey
JOIN table2HPE ON OA.hprptentityid = HPE.hprptentityid
Join table3ME on OCR.MbrEligKey = ME.MemberEligKey
Join table4LDI on OCR.PrvID = LDI.PRVID
Join table5LG on OCR.AddrKey = LG.Addrkey
HPE.KeyWord in (
order by  OCR.medrecactkey desc

Open in new window

  • 2
2 Solutions
Why not specifically create the table before running the process

create table #tempPX


Then do insert into #tempPX select ...
patd1Author Commented:
I found the problem. The OCR table has this field as int and LDI has varchar in it. I changed my join on and it works now.
An INT field I believe can only store numbers up to 2,147,483,647.

You will have to change the datatype in the target table to BIGINT.
patd1Author Commented:
my mistake.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now