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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error converting varchar to int

Status
Not open for further replies.
Joined
Dec 11, 2009
Messages
60
Location
US
I have a report I am creating and need to select data based on a certain zip codes:

zipcode in (97124,97140,97224,972310,97850). I am getting the below error:

Syntax error converting the varchar value '97850-7223' to a column of data type int.

Because one of the fields in the database is: 97850-7223?

How can I get around this error when there are zip codes as above with the dashes in it?

Thanks,
 
Your code
Code:
zipcode in (97124,97140,97224,972310,97850)
needs the quotes
Code:
zipcode in ('97124','97140','97224','972310','97850')
You will also have a problem in comparing a zip plus four to the five digit criteria.

djj
The Lord is My Shepard (Psalm 23) - I need someone to lead me!
 


Hi,

Although this FAQ was written with Excel in mind, it is applicable...

faq68-6659

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top