Archived

This topic is now archived and is closed to further replies.

johnc82

Access SQL Problem...

Recommended Posts

hi.. /*Postcode is a numeric data type by default*/ SELECT CAST(Postcode AS CHAR(5)) FROM Person; i wanted to cast or convert Postcode from numeric data type to char or text data type... however it stated an error which is: Syntax error (missing operator) in query expression CAST(Postcode AS CHAR(5))''. But by default it should work... anyway anyone can help or fix this error? Thanks A LOt... :-)

Share this post


Link to post
Share on other sites
CAST is only good for converting between different numeric types (and dates/times). You don''t have to do anything special to get numeric types to act like strings, though (or vise versa for that matter). For example, the following:

SELECT CONCAT( ''This is a number: '', 1234 )

Would return "This is a number: 1234" as expected.

If I had my way, I''d have all of you shot!


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
Use CONVERT instead of CAST

This may be no help - I know this is how to do it in Microsoft SQL - but as for Access... afraid I don''t have it installed (cos it is just above "Mostly Useless" for databases... )

Share this post


Link to post
Share on other sites
THANK!

SELECT CStr([person]![postcode]) AS postcode
FROM person;

WORK!

by the way where can i find a complete SQL reference for microsoft acess which tell me what kind of SQL syntax can be use in it....
i know they are using mircosoft jet SQL in acess....
so any reference, e-book or web site....????

Thanks alot...

:-)

Share this post


Link to post
Share on other sites
Try here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acfundsql.asp


"It is precisely because it is fashionable for Americans to know no science, even though they may be well educated otherwise, that they so easily fall prey to nonsense. They thus become part of the armies of the night, the purveyors of nitwittery, the retailers of intellectual junk food, the feeders on mental cardboard, for their ignorance keeps them from distinguishing nectar from sewage."
Isaac Asimov

Share this post


Link to post
Share on other sites