Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    upnxT is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    5

    A rather odd SQL quirk in Access

    Hello all,

    I have a rather random question (or query...).

    I am doing this little example to demonstrate some SQL commands via Access. It is a CREATE TABLE. I run it like so:

    CREATE TABLE temperature

    (

    city VARCHAR(30),



    state VARCHAR(30),

    high INT (3),

    low INT(3),

    ;

    -----------------------

    The syntax seems to come up fine on sites like SQL fiddle, but Access hangs on the bracket just after INT (if I try to change to DECIMAL it just hangs on that instead).

    I'm very confused as these are rather simple commands and I've never had this trouble before.

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you have a superfluous comma after your last int and a superfluous bracket before city

  3. #3
    upnxT is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    5
    I removed both and it just moved the syntax error to the first VARCHAR.

    I can understand removing the last comma.

    Here is what I have now, same problem:

    CREATE TABLE temperature

    (

    city VARCHAR(30),

    state VARCHAR(30),

    high INT (3),

    low INT(3)

    )

    ;

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    CREATE TABLE temperature

    (

    city VARCHAR(30),

    state VARCHAR(30),

    high long,

    low long

    )
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    What is the error you are actually getting?

    not sure if varchar is correct for access (perhaps it is for 2016) - try text. And int may be integer?

    See this link for datatypes in Access

    http://www.w3schools.com/sql/sql_datatypes.asp

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    varchar will work fine in Access, I tested the SQL I posted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Another example of Create Table with MS Access SQL showing Int
    Attached Thumbnails Attached Thumbnails createTableSQL.jpg  

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by orange View Post
    Another example of Create Table with MS Access SQL showing Int
    I don't see Int.

    Int will actually work alone, it's the "(3)" that seems to cause a problem. I assume Access doesn't understand it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Old eyes got distracted by Integer and missed Int.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  12. #12
    upnxT is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    5
    Hi all,

    sorry to be simplistic, but what would the problem with the 3 be here then?

    The error I get is that it hangs on the bracket before 3. I have added a screenshot.Click image for larger version. 

Name:	Untitled.png 
Views:	9 
Size:	7.2 KB 
ID:	25366

  13. #13
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    You are trying to tell Access how to reserve storage for an Integer (number datatype). You have 2 choices -set by Access --integer or Long ONLY. Unlike Text or char or varchar where you can provide "the amount of storage to be used as default". There may be more details, but that's it in overview.


    Microsoft Access Data Types
    Data type Description Storage
    Byte Allows whole numbers from 0 to 255 1 byte
    Integer Allows whole numbers between -32,768 and 32,767 2 bytes
    Long Allows whole numbers between -2,147,483,648 and 2,147,483,647 4 bytes
    Single Single precision floating-point. Will handle most decimals 4 bytes

  14. #14
    upnxT is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    5
    Hmm, it seems that if I simply remove the restriction of the number it works, i.e. remove (3).

    Is this normal?

  15. #15
    upnxT is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    5
    Quote Originally Posted by orange View Post
    You are trying to tell Access how to reserve storage for an Integer (number datatype). You have 2 choices -set by Access --integer or Long ONLY. Unlike Text or char or varchar where you can provide "the mount of storage to be used as default". There may be more details, but that's it in overview.
    I am getting it now! Just for my own head's visualisation what command should I be using then?

    high [then what?]

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums