• Register
1 vote

Problem :

I am new to SQL. While trying to execute my JOIN query I am facing below strange error.

“Conversion failed when converting the varchar value to data type int”.

I am unable to figure out why am I getting above error. Can someone help me in fixing the error?

8 5 2
3,230 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution :

I am trying to answer your question as I found it interesting.

I think you are a very new to SQL and you are trying to convert the column containing that appears to me as a character values to the int values

As your value is not the valid INT so you are facing above mentioned error. You need to consider many things to avoid such errors.

Is your column supposed to be a char or varchar data type and if that is so then are the non integer characters also expected or allowed in your data?

If this is not the case then:

1.  Have some incorrect data entered by somebody in your test data?

2.  Why this is not the int column to make your DB enforce this thing

If this is the case then why are you casting it to the int?

·  Is your table which you are joining to is also using the integer identifier?

8 4 1
5,680 points

Related questions

0 votes
1 answer 567 views
Problem : I have the table storing starttime and endtime. I am facing below error: “Conversion failed when converting character string to smalldatetime data type.” While selecting the below query using that table. select CAST(substring(CONVERT(varchar,convert(smalldatetime,o. ... face any error. But, when I select it from a table I got the error. Can somebody help me with this?
asked Jan 20, 2020 jwilliam 3.9k points
0 votes
1 answer 12 views
I received an error message when converting data type varchar to numeric I imported data into VARCHAR column to check correct character types before moving into the destination table. I ran across some decimal values they could not CAST or CONVERT even though they ... values. I received the message "Error converting data type varchar to numeric.” How can I load these problems values?
asked Nov 24, 2020 miki 1.9k points
0 votes
1 answer 30 views
Probelm: The conversion of the varchar value overflowed an int column.
asked Feb 16 Ethan ross 2.3k points
1 vote
1 answer 257 views
Problem: I am having good exposure to SQL. Currently I want to insert my data from one table to the another table but because of some unknown reason to me I am facing some sorts of issue it shows me below error: Numeric value out of range: 8115 [Microsoft][ODBC ... ,'') AS [TRIM(IngredCost)]  FROM file_5979bd211a3a9` Please help me with this issue. I want to insert all the records in one go.
asked May 23, 2020 Martin K 6.6k points
1 vote
1 answer 231 views
Problem: I have very basic knowledge in Sql query writing. I have tried to write the below query. SELECT '$'        + CONVERT(VARCHAR (6), Cast(Avg(TotalPrice) AS NUMERIC (6, 2))) AS 'Average Price',        '$'        + CONVERT(VARCHAR (6), Cast(Min( ... converting numeric to data type varchar". I am unable to find the root cause of above error. Kindly help me in fixing my above sql query.
asked May 23, 2020 Martin K 6.6k points
0 votes
1 answer 78 views
Problem : I was getting the following error when running a SQL the conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
asked Nov 12, 2019 peterlaw 6.9k points
1 vote
1 answer 44 views
Problem: I am having only elementary knowledge about Sql Server and Azure. I have gained basic knowledge about Sql server and Azure from the available online material. I want to write a very basic query that should calculate the average, min, max, and count. ... this part of programming so unable to understand the above error. Kindly guide me in fixing above Sql Server and Azure related error.
asked Jun 6, 2020 Martin K 6.6k points
0 votes
0 answers 1 view
1 view
Problem: Please assist me in resolving this issue: sql server error converting data type varchar to float
asked 11 hours ago rakib1 51.3k points
0 votes
0 answers 1 view
1 view
Problem: Please help me: sql error converting data type varchar to float
asked 11 hours ago rakib1 51.3k points