Help MS SQL Query - Conversion failed when converting the nvarchar value '4917,' to data type int.

Hello Experts,

I've got an MS SQL query running on an ASP page, it's been working fine until now.

Now however when it runs on the ASP page i get the following error -

"Microsoft OLE DB Provider for SQL Server error '80040e07'
Error converting data type nvarchar to float.
/js/codes/cvapplication.asp, line 30 "

so when i test the query in MSSMS (2008) I get the following error -

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '4917,' to data type int.

I'm really confused as the record concerned doesn't have a lcolumn that contains the value '4917'

Please help
SELECT 
Top(1) 
AP.JBAPID, 
(S.JBSURL + AP.JBAPCV) As JBAPCV, 
AP.JBAPCandidateID, 
AD.JBAID, 
AD.JBATitle, 
AD.JBAConkersEmail, 
C.JBACAUsername, 
E.JBEName, 
E.JBEUsername, 
S.JBSURL, 
S.JBSURLShort, 
S.JBSNoReplyEmail 
FROM dbo.JBApplication AP 
inner join dbo.JBAdvert AD 
on AP.JBAPAdvertID = AD.JBAID 
inner join dbo.JBEmployee E 
on E.JBEID = AD.JBAEmployeeID 
inner join dbo.JBSite S 
on S.JBSSiteID = AP.JBAPSiteID 
inner join dbo.JBACandidate C
on C.JBACAID = AP.JBAPCandidateID 
WHERE AP.JBAPCandidateID = 3750 AND S.JBSSiteID = 30 
Order by AP.JBAPID DESC

Open in new window

garethtnashAsked:
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.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
I presume the problem is here:
(S.JBSURL + AP.JBAPCV) As JBAPCV,


either of the 2 is int, the other is varchar.
apply a CAST(yourfield as varchar(10))  for the int field
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the problem could also be here:
WHERE AP.JBAPCandidateID = 3750 AND S.JBSSiteID = 30
garethtnashAuthor Commented:
Hi Angelllll,
 just to let you know that the AP.JBAPCV data is -
/CVS/Danx Marden CV_1.doc
and the  S.JBSURL data is -
http://www.awebsite.com.
 
This has worked fine until yesterday?
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

garethtnashAuthor Commented:
The situation looks slightly worse...
 
In as much as if I change the query to read just -
 
"select *
from dbo.JBApplication
where JBAPCandidateID = 3750"
 
So I'm only selecting from one table...
I see the results for a millisecond and then I get the following -
 

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '4917,' to data type int.
 
Help
speight040Commented:
Do you get this error on the asp page?
Have you tried running the select statement in isolation in SQL Server Management Studio (or other SQL tool)?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
it could as well be any of the joins, where one of the fields is int, the other varchar.

'4917,'

shows clearly that the field in question contains a "," at the end.
this was presumably changed

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
garethtnashAuthor Commented:
Angellll,
 
well spotted, somehow one of the columns which should have had just 4917 has been updated to read '4917,'.
 
I've got no idea how this happened, but the offending ',' has been removed.
 
Many thanks
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
ASP

From novice to tech pro — start learning today.