SQL Error_overflowed an int column

SELECT COL1,COL6, COL8
FROM FEB_06
where col8 = cast('130' as int)

if I run this on Query Analyser I get this error:

"Server: Msg 248, Level 16, State 1, Line 1

The conversion of the nvarchar value '  6787681034' overflowed an int column. Maximum integer value exceeded."

COL1, COL6, COL8 are all nvarchar(100) datatype on SQL Server 2000.

I I remove the cast on '130' it retuns zero data matches, am sure tere are many 130 records on te table.
LVL 1
matidaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
matida,
> cast('130' as int)
 
U need to cast it as Bigint
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if col8 is of type nvarchar, your query should really be like this:

SELECT COL1,COL6, COL8
FROM FEB_06
where col8 = N'130'
matidaAuthor Commented:
this returned no matched resullts, just as without the 'N'.  BUT am VERY SURE there are many records for '130'
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
>nvarchar(100)
just to be sure: nvarchar and not nchar(100)

>BUT am VERY SURE there are many records for '130'
can you post some sample data from the table regarding the contents. just for US to be sure...
Aneesh RetnakaranDatabase AdministratorCommented:
SELECT COL1,COL6, COL8
FROM FEB_06
where LEFT(col8,3) = '130'

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
matidaAuthor Commented:
ANEESH!
If  I use CAST as Bigint, I get this error :
"Error converting data type nvarchar to bigint"

angelIII!
AM SURE THEY ALL 'NVARCHAR'. below a sample data captured:

COL1, COL2, COL3, COL4, COL6,  COL8,  COL14, COL15, COL16
001-00,      004-00,      02-14-2006 01:32:11,         00:31:56,  4393301, 6787681034, 01:32:05, 01:32:05, 01:32:11
000-00,      004-00,      02-14-2006 09:11:41,00:01:31,   7787757,  4798683782, 09:11:20,09:11:25,      09:11:41

011-00,      004-00,      02-14-2006 09:14:24,      00:00:01,                      130,        44123456789,09:14:11,      09:14:17,      09:14:24

000-00,      004-00,      02-14-2006 09:29:13,      00:04:42,                      7787757,        4798683782,      09:28:54,      09:28:59,      09:29:13
matidaAuthor Commented:
ANEESH!
using > where LEFT(col8,3) = '130'
no macthed results at all. this is amazing, coz there are '130' records on the table.
matidaAuthor Commented:
I managed to use this one and it works:

SELECT COL1,COL6, COL8
FROM FEB_06
where LTRIM(COL8) = N'130'

the points are for u both, siince solution is a combetion of ur suggestions
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I guess the table contents comes from some external file?
matidaAuthor Commented:
ACTUALLY, the table imported to SQL server from Text, then exported to Access, then re-imported to SQL server.....
matidaAuthor Commented:
u seem to grab all my points AngelIII! hehehe!! g me some back pls....jusk kidding :-)
am in Gambia, here very very few developers in the country...apart from the net, dificult to get somebody help u out...thanks to expert-exchange lol!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.