Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL question - Syntax error -

Status
Not open for further replies.

MDA

Technical User
Jan 16, 2001
243
US
Hi all,

I am getting an error when I test a select statement in query Analyzer.

The statement is:
select accocode, acconame from acco where accocode in(61003,61005,61007,61011)
The Error is:

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value 'ACCDEP' to a column of data type int.

If I put Single Quotes around the accounts like...
...in('61003','61005','61007','61011')
Then it works fine... However, I am inherting these accounts from something else and cannot put the single quotes...

Is there a way to get the results without the Single quotes??

Any help is greatly appreciated..

regards,
MIke
 
I am inherting these accounts

I assume you mean you are inheriting the data, not the SQL commands. Putting in the quotes is required because the column being searched is character, and the quotes denote a character literal. Putting the quotes in the Select statement doesn't change the data, so you should not have any adverse affects from using them. Robert Bradley
Got extra money lying around? Visit:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top