I have an odd problem in SQL Server. Basically we have a generic type object with two columns, Description 1 and Description 2. We check if Description2 is a number and if it is, check the value/use it. However I am getting the following error when attempting to run the query.
Conversion failed when converting nvarchar value 'Test Other' to data type int.
Now normally I would simply assume that it was attempting to join on improper values/etc, but the varchar it's saying in the error should not be valid from the ISNUMERIC.
Here is a sample of my query:
SELECT *
FROM base_table
JOIN org_type o ON o.id = base_table.org_id
LEFT JOIN generic_object go ON go.id = base_table.org_id AND ISNUMERIC(description2)
WHERE description2 = @orgId
AND base_table.id = @baseId
What is strange to me, when I remove the last line from the query, I do not receive an error.
@baseId? Tell us both the datatype and value.'Test Other'is coming from?