• SQL Statement and quotes

    Author
    Topic
    #353721

    Background:

    I place a batch of names and ID numbers into a table using the following SQL statement:
    INSERT INTO tablename (

    Viewing 0 reply threads
    Author
    Replies
    • #518055

      Why would you have quotes around the field names? You definitely don’t need them in Access. I’m assuming the quotes around the values represent strings. You can just embed double quotes in the SQL instead of single quotes, which takes care of the apostrophe problem. Of course, that won’t work in SQL Server, but it does in Access. If you’re building the SQL in code, you can use three double quotes in sequence to represent a single instance of a double quote (say that three times fast ).

      • #518060

        They are strings which I’m using.

        Basically, I have an array of 5 strings which make up a record in a table.

        Is there any other possible way of inserting the record into the table without using an INSERT statement?

        James

        • #518061

          Excuse me? Your strings are the values you want to insert, right? So what’s the problem with the insert statement? The alternative is to open a recordset and use AddNew to add a new record so you can populate the fields with the string values. However, it’s slower.

          • #518063

            Yes. Some of the strings contain apostraphes (single quotes) and some of the strings have a length of 127 and for some reason the SQL statement chops some of the length of and therefore falls over.

            I’ll try a recordset suggestion.

            Thanks for the help so far!

            James

    Viewing 0 reply threads
    Reply To: SQL Statement and quotes

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: