SQL Conversion failed when converting the varchar value to data type int -


i have query:

select c.customerid,         q.question_id,         q.department,          c.duedate   homefront.dbo.tpm_questions_default q   left outer join homefront.dbo.customerquestions c      on q.question_id = c.questionid  inner join tblcustomers t      on convert(int, convert(varchar(max), t.customer_no )) = c.customerid  c.duedate <= getdate() , c.datecompleted not null 

i added in inner join tblcustomers t on convert(int, convert(varchar(max), t.customer_no )) = c.customerid

now error:

conversion failed when converting varchar value 'c000432' data type int. 

you converting (casting) column containing appears character values int values

convert(int, convert(varchar(max), t.customer_no )) 

since value c000432 not valid int, getting error. there's several things consider:

  • is customer number supposed char / varchar data type , if so, non integer characters expected / allowed in data?
  • if not:
    1. has incorrect data snuck in (the c character) - test data?
    2. why isn't int column begin (to make db enforce this)
  • if so, why casting int?
    • is table joining using integer identifier?
    • do need strip off leading 'c' character before casting int?

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -