July 22, 2013 at 12:05 pm
Hi All,
Im not the greatest at SQL but Im getting better. I do not understand why I get the following error in my simple select query. I get the (Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar to numeric.)
SELECT
ed.[Employee Name],
bd.SORTUSER_EMPID,
bd.SORTDTTM
FROM
[BOXES].[dbo].[BOXDETAILS_ORL] bd
JOIN
[Employee].[dbo].[Employee Data] ed
ON
bd.SORTUSER_EMPID = ed.[Employee ID]
WHERE
SORTDTTM >= dateadd(day,-30,getdate())
July 22, 2013 at 12:12 pm
July 22, 2013 at 12:15 pm
I can query the one box table but when I add the join and include bringing in the employees name it give me the error, and I cannot figure out which line it is. Plus I dont understand what your asking for with table definitions, sorry. But I am just trying to get the persons name, next to their EMPID and the sorted date time. (SORTDTTM.)
July 22, 2013 at 12:15 pm
i would guess it's due to the joins:
bd.SORTUSER_EMPID = ed.[Employee ID]
i think maybe one column is an integer or numeric column, and the other is varchar?
due to data type precedence, the varchars are being converted to integer, and some values are not actually numeric:
try converting to a varchar join for teh data type, since it's being implicitly converted anyway?
CONVERT(varchar,bd.SORTUSER_EMPID) = CONVERT(varchar,ed.[Employee ID])
Lowell
July 22, 2013 at 12:16 pm
My guess is that one of the columns bd.SORTUSER_EMPID or ed.[Employee ID] is numeric and the otherone is a varchar and contains a non-numeric value. This error would be caused by an implicit conversion. To avoid it, cast the numeric column as varchar and consider changing the data types from your columns to the adequate data types.
EDIT: Lowell had the same guess than me and posted faster than me 😀
July 22, 2013 at 12:18 pm
Thanks Lowell, That was it. 😀
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply