Insert into Ms Access

Last post 07-02-2008 1:23 PM by TonyDong. 5 replies.

Sort Posts:

  • Insert into Ms Access

    06-24-2008, 6:59 PM

    Hi Members,

    I tried to insert some values in to a tale in MS access. But I keep getting the message "Expected semi-colon (;) at the end of sql statement"

    Here is the query I tried inserting

    INSERT INTO dynamic_values VALUES(1,'test','test') WHERE not exists (SELECT 1 from dynamic_values WHERE agreement_id = 1 and dynamic_label = 'test' and dynamic_value = 'test' )

    My scenario is that the table must not allow duplicate values to be inserted into the table.

     Kindly suggest on this.

    Thanks

    Filed under:
  • Re: Insert into Ms Access

    06-24-2008, 7:17 PM
    • Loading...
    • TonyDong
    • Joined on 02-01-2006, 6:30 PM
    • BC, Canada
    • Posts 744

    Did you try to add semi-colon like

    INSERT INTO dynamic_values VALUES(1,'test','test') WHERE not exists (SELECT 1 from dynamic_values WHERE agreement_id = 1 and dynamic_label = 'test' and dynamic_value = 'test' ) ;

    Don't forget to click "Mark as Answer" on the post(s) that helped you.
  • Re: Insert into Ms Access

    06-25-2008, 6:16 PM

    No luck :(

    still I get same error "Missing semicolon (;) at the end of sql statement"

  • Re: Insert into Ms Access

    06-25-2008, 7:10 PM
    • Loading...
    • hans_v
    • Joined on 01-29-2007, 4:03 PM
    • Posts 203

    SELECT 1 FROM dynamic_values? Try this:

    INSERT INTO dynamic_values VALUES(1,'test','test') WHERE not exists (SELECT * from dynamic_values WHERE agreement_id = 1 and dynamic_label = 'test' and dynamic_value = 'test' )

  • Re: Insert into Ms Access

    06-27-2008, 6:13 PM

    Hi,

    I've even tried of this, SELECT * FROM <tableName>.

    I just want to idealize the performence.

    Whwt I try to do in this query is that, I wan t to restrict the data to be inserted into the table if <they alreay exists> for the condition I mentioned.

    Can you suggest a way I could achive this!

    Thanks,

  • Re: Insert into Ms Access

    07-02-2008, 1:23 PM
    • Loading...
    • TonyDong
    • Joined on 02-01-2006, 6:30 PM
    • BC, Canada
    • Posts 744

    If you try

     

    IF NOT EXISTS(SELECT * FROM TABLE)

    INSERT INTO TABLE (column) VALUES(value)

    It will works.

    Don't forget to click "Mark as Answer" on the post(s) that helped you.
Page 1 of 1 (6 items)
Microsoft Communities
Page view counter