locked
Double quotes in error messages! RRS feed

  • Question

  • I have a problem when trying to display an error message from sql server 2005 on a web page with an alert (javascript command).

    The Sql server 2005 returns a message like:

    Insert statement conflicted with foreign key constraint "bla bla". The conflict occured indatabase "databasename", table "tablename", column 'columnname'.

    In sql server 2000 the error message is the same except all names (constraint, database, table) is in single quotation marks; just like the columnname in the above example.

    Is it a configurable issue on the sql server. I would prefer not to solve this issue on a number of different web pages!

    Thanks in advance.

    Futte

    Tuesday, July 3, 2007 10:16 AM

All replies

  • hi,

     

    you should set this:

     

    SET QUOTED_IDENTIFIER { ON | OFF }

     

    When on, then identifiers can be delimited by double quotation marks.

     

    Regards,

     

    Janos

    Tuesday, July 3, 2007 10:22 AM
  • I all ready tried that without any luck.......

    I want to avoid the double quotation marks.

    Thanks though

    Futte

    Tuesday, July 3, 2007 10:30 AM
  • If you wish to 'embed' single quotes in your message, you need to double them up -use two single quotes in each place of one single quote.)

     

    Try this: 

     

    SELECT 'This is my ''message'' with quotes.'

    Tuesday, July 3, 2007 7:19 PM
  • I think my question might be a little misunderstood.

    My question is not about query syntax in sql regarding single or double quotation marks or two single quotation marks.

    It's about the error message sql server is returning. I suddenly experienced that after upgrading sql server from 2000 to 2005 the response from sql 2005 contained double quotation marks around all object names except for one; namely the column name:

     

    2000:

     

    Insert statement conflicted with foreign key constraint 'constraint name'. The conflict occurred in database 'database name', table 'table name', column 'column name'.

     

    2005:

     

    Insert statement conflicted with foreign key constraint "constraint name". The conflict occurred in database "database name", table "table name", column 'column name'.

     

    This is a problem when displaying the error message on a web page with javascript (alert). So if it's a configurable issue on the sql server where is it set? Otherwise I have to handle this error message somewhere else replacing the double quotes with single quotes.

     

    Kind Regards

     

    Futte

    Wednesday, July 4, 2007 5:45 AM
  • Thanks for the clarification. I better understand the situation.

     

    As far as I am aware, there is no user configurable setting to alter the presentation of the error message.

    Wednesday, July 4, 2007 6:45 AM