Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Simple Query Getting an Error

Author  Topic 

dtrivedi
Posting Yak Master

153 Posts

Posted - 2010-10-18 : 11:36:39
I'm running this simple select statement but getting this error. What does this error mean?
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'MAC0003' to data type int.
SELECT [EMPLOYEE_NUM]
,[LAST_NAME]
,[FIRST_NAME]
,[PRIMARY_LOCATION]
,[PRIMARY_DEPT]
FROM [CACTUSDB].[dbo].[TBLEMPL10]
where EMPLOYEE_NUM in (907514,
905895,
905753,
907106,
906742,
902029,
906845,
908154,
906264,
905580,
905723,
904010,
907553,
903551,
905026,
906246,
906666,
900193,
900194,
905795,
900467)
GO

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-18 : 11:40:27
That means in your column EMPLOYEE_NUM are values that can't be converted to INT.
The convert happens because the values in your IN() are integers.
Use this instead:
where EMPLOYEE_NUM in ('907514',
'905895',
'905753',
...
)




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

dtrivedi
Posting Yak Master

153 Posts

Posted - 2010-10-18 : 11:45:03
thanks alot!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-18 : 11:51:11
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -