Results 1 to 5 of 5

Thread: Question mark in column name

  1. #1
    Join Date
    Mar 2003
    Posts
    2

    Question mark in column name

    One of the tables in my database was originally designed with a question mark in the column name. When creating my query for jdbc i did this:

    String q = "o.\"Cancelled?\" from ORDERS o";

    However, this query gives me the following error message:

    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Cancelled@P1'.

    Is there a way of stopping the driver from turning the '?' into '@P1'?

    I have tried single quotation marks instead of the double ones around the column name and also back ticks, but with no success.

    I have also seen an option in a local ODBC connection I have created an option for ansi quoted strings which solves the problem for oDBC queries, is there an equivilant for JDBC?


    Thanks to anyone able to help!

    Sincerely,
    Andrew

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    I have not used jdbc but in transact sql you could use [] to enclose the column name to tell the server to not use the special meaning of ?

    Try it out, may be it works

  3. #3
    Join Date
    Sep 2002
    Posts
    5,938
    Did you try reference table as [Cancelled?]?

  4. #4
    Join Date
    Mar 2003
    Posts
    2
    Thanks for the info, but alas it doesn't seem to do anything different that the double quotation marks, so far I have tried:

    o."Cancelled?"
    o.[Cancelled?]
    o.'Cancelled'
    o.`Cancelled`

    the first two turn the ? into @P1
    the others give me invalid syntax

    My guess is that it is taking the ? to mean a parameter (i.e. the first parameter). Is there a way to stop it from doing this?
    Last edited by ajmirsky; 03-17-2003 at 11:18 AM.

  5. #5
    Join Date
    Sep 2002
    Posts
    5,938
    How about o."[Cancelled?]"?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •