• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3366
  • 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.
Error:
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
INTO #TempPX
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
where 
HPE.KeyWord in (
'ABC27751PI',
'ABC27752PI'')
order by  OCR.medrecactkey desc

Open in new window

0
patd1
Asked:
patd1
  • 2
2 Solutions
 
twolCommented:
Why not specifically create the table before running the process

create table #tempPX
(...

)

Then do insert into #tempPX select ...
0
 
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.
0
 
BusyMamaCommented:
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.
0
 
patd1Author Commented:
my mistake.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

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