2

This is my table

CREATE TABLE tab_customerxml 
(
    id INT IDENTITY, 
    xmldata XML
)

and I loaded an xml with insert.

I want to run this simple query

SELECT 
    xmldata.query('/customer')
FROM 
    tab_customerxml 
WHERE 
    id = 4;

but I get this error:

Can not run because select the settings of the following SET options are incorrect QUOTED_IDENTIFIER.

I do not know how to solve this problem.

Thank you

3
  • Side note: since your id column is of type int, you should use this notation in your WHERE clause: WHERE id = 4 - don't add those unnecessary single quotes - this makes our '4' a string, which has to be implicitly converted back to an Int ..... if it's an int - don't use any single quotes to begin with Commented May 25, 2016 at 20:56
  • I changed where id = 4 but does not work the same @marc_s Commented May 25, 2016 at 21:00
  • also without where statement , I always get the same error Commented May 25, 2016 at 21:03

1 Answer 1

1

Try to run this:

  • drop your table

    DROP TABLE tab_customerxml;
    
  • re-create it with the proper settings on:

    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    SET ANSI_PADDING ON
    
    CREATE TABLE tab_customerxml 
    (
       id INT IDENTITY, 
       xmldata XML
    )
    
  • now try your query again

    SELECT xmldata.query('/customer')
    FROM tab_customerxml 
    WHERE id = 4;
    

Does that help?

Sign up to request clarification or add additional context in comments.

2 Comments

thanks it works. but I did not understand what was the problem
@Genny: as the error clearly says: the setting for QUOTED_IDENTIFIER was wrong. Not sure why - but adding these three SET .... ON lines before creating your table works for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.