SQL Query Create Table Decimal Field


Either my brain isnt quite functioning tonight or there is something wrong.

In MS Access 2003 i open up the Query designer and select SQL View

I type in CREATE TABLE ProductCode(MinWeight Decimal(5, 2))

And the Decimal comes up as a syntax error

So does

How do i create a Decimal field in MS Access using the query designer in SQL View.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi adam_pedley,
I don't believe you can.
I think you have to use an ADO statement in VBA to execute the SQL string.

    CurrentProject.Connection.Execute strSql

Your first attempt looks OK to me.

Leigh PurvisDatabase DeveloperCommented:
What is it you're trying to achieve?
You'll have to use the Jet accepted equivalents.

You mentioned Double - but just substituting Decimal in your statement won't work but
CREATE TABLE ProductCode (MinWeight Double)
Rory ArchibaldCommented:
Not sure if it's the same in 2003 as it is in 2002, but under Tools-Options on the Tables/Queries tab, there is an option to use ANSI 92 syntax. If you check this, it will allow your statement to run. However, it will also expect all queries to use ANSI 92 syntax and expect different wildcards (% rather than *) so may well not be worth it! The alternative is to create the table in code, I guess.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

This from A2K Help - probably the same still for A2003

Decimal data type
A data type that contains decimal numbers scaled by a power of 10. For zero-scaled numbers, that is, numbers with no decimal places, the range is +/-79,228,162,514,264,337,593,543,950,335. For numbers with 28 decimal places the range is +/-7.9228162514264337593543950335. The smallest non-zero number that can be represented as a Decimal is 0.0000000000000000000000000001.

Note that at this time the Decimal data type can only be used within a Variant. You cannot declare a variable to be of type Decimal. You can, however, create a Variant whose subtype is Decimal using the CDec function.
adam_pedleyAuthor Commented:
Thanks all

rorya solution worked

I was actually just using it to create SQL statements to test them.

Just curious, do you have a Decimal datatype in A2003?
adam_pedleyAuthor Commented:
Well when you create a table in design view you choose the data type of number then field size of decimal. I thought it was always there though.

Im creating the tables in SQL using queries in SQL View.
Rory ArchibaldCommented:
Incidentally, if you run that SQL in ADO - a simple currentproject.Connection.Execute "CREATE TABLE ProductCode(MinWeight Decimal(5, 2))" command - it works perfectly, so it seems to be purely a limitation in the query designer.
That SQL in the Query Builder in A2K generates an error on the datatype.  Ergo, I think you have a Decimal datatype in A2003.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.