Results 1 to 4 of 4
  1. #1
    crystalclear is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    2

    Access SQL Syntax For Creating a Table With a Default Constraint

    Hello,



    I have used Access for a number of years but now I'm taking a class on database programming which is teaching SQL as part of the course. I'm trying to learn how to create a table with SQL statements in the query design window. The book that I'm using just gives the default SQL statement for using SQL but it isn't specific to Access. If I use the statements that the book is using I get an syntax error. I will type the code below and hopefully someone can tell me what I'm doing wrong. I desperately need help.

    Here is the code:

    CREATE TABLE OrderItems

    (
    order_num INTEGER NOT NULL,
    order_item INTEGER NOT NULL,
    prod_id CHAR(10) NOT NULL,
    quantity INTEGER NOT NULL DEFAULT 1,
    item_price DECIMAL(8.2) NOT NULL
    );


    The line that is bolded is the one I'm having trouble with. I keep getting a syntax error. What is the matter? Also, what value should I specify for the second to the last line of code that specifies that the item price is a decimal? Decimal doesn't seem to be a recognized code in value in access.

    Thanks for any help someone can give me.

    Joel Wiggers






  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Access doesn't recognize either DEFAULT or DECIMAL.

    I don't know if can set DEFAULT in the sql action. I think have to set this after the table is created.

    Use DOUBLE instead of DECIMAL.

    Review http://web.synametrics.com/defaultvalaccess.htm
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    crystalclear is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    2

    Arrow Continued Question

    Quote Originally Posted by June7 View Post
    Access doesn't recognize either DEFAULT or DECIMAL.

    I don't know if can set DEFAULT in the sql action. I think have to set this after the table is created.

    Use DOUBLE instead of DECIMAL.
    that
    Review http://web.synametrics.com/defaultvalaccess.htm

    Okay, thanks for the help. Is there a resource on this website where I could find the entire SQL syntax for Access? I'm continuing to have trouble with implementing the code that this book is telling me to use compared to the code that works in Access there seems to be quite a difference.

    Joel

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I don't know any resources specifically for using SQL in Access. The syntax is basically the same, but apparently some keywords not recognized.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Referential integrity constraint
    By dsaxena15 in forum Access
    Replies: 3
    Last Post: 09-27-2012, 02:07 PM
  2. How do I display SQL constraint errors?
    By isabelle2378 in forum Forms
    Replies: 3
    Last Post: 10-19-2010, 03:23 PM
  3. Student Access user, need help creating a table
    By racheliza79 in forum Database Design
    Replies: 3
    Last Post: 08-07-2010, 01:08 PM
  4. On delete cascade fails in constraint clause
    By Victor EGBE in forum Queries
    Replies: 0
    Last Post: 03-02-2009, 09:52 PM
  5. Access 2003 - Creating Buttons from a Table
    By Speedy in forum Programming
    Replies: 2
    Last Post: 02-28-2009, 05:32 PM

Tags for this Thread

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