Results 1 to 5 of 5
  1. #1
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    313

    Using double quote as text delimiter

    When I use ADODB in VBA to query an Access table for a string, I use syntax such as SELECT * FROM CUST WHERE COMPANY_NAME = "JOHN'S SERVICE COMPANY"... This works fine when I'm querying an Access Database. However, when I try to use this syntax to query a table on SQL Server 2008 R2, it returns a syntax error. When I change the delimiting double quotes and replace them with single quote, it works fine... providing there isn't a single quote within the COMPANY_NAME, as there is in this case. The problem is that I need the query to work even if the data contains one or more single quotes. Is there a setting on SQL Server that I can set to make it accept the double quote delimiter convention? Thanks, Eddie

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Never used SQL Server but I doubt it.

    I am surprised syntax works for Access. I had to create code to handle apostrophes in data. Like:

    strValueList = strValueList & ", '" & Replace(strSampledFrom, "'", "''") & "'"
    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
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    313
    I think if you set the database property QUOTED_IDENTIFIER to OFF, it's supposed to work like I want this to. However, I haven't figured out how to set that property yet. Any suggestions?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Sorry, no, I don't know SQL Server.
    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.

  5. #5
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    313
    Okay, guys and gals, I have figured this out... First, the option

    SET QUOTED_IDENTIFIER OFF or FALSE does, in fact, solve the problem...

    Now, if you have authority to change this setting for the database, you should set the database,
    properties, options of

    SET QUOTED_IDENTIFIER False

    If not, when you format the SQL Select string, put

    SET QUOTED_IDENTIFIER OFF

    just before the SELECT keyword. Be sure to put a space between the OFF and SELECT.

    Hope this helps someone.

    Eddie

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

Similar Threads

  1. Using pound sign as date delimiter
    By EddieN1 in forum SQL Server
    Replies: 1
    Last Post: 03-07-2012, 10:38 PM
  2. Replies: 0
    Last Post: 10-06-2010, 11:56 AM
  3. Replies: 0
    Last Post: 08-06-2010, 06:45 PM
  4. Replies: 3
    Last Post: 01-15-2010, 02:28 PM
  5. The search for "quote symbols"
    By Dadmail in forum Queries
    Replies: 1
    Last Post: 03-18-2009, 10:52 AM

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