Thursday, March 22, 2012

escape character if the field name has ? in it

HI All,
I'm using SQL server 2000 and SQL Server JDBC driver to connect to it.
I have a field name which has a ? in it. For eg field?
In the query analyzer when i execute the following query
select field? from qtable. It executes successfully. In the Java code
I tried the same like ResultSet rs = stmt.executeQuery("Select field? from
qtable");
The following exceptions was thrown [Microsoft][SQLServer 2000 Driv
er for JDBC][SQLServer]Invalid column name 'field@.P1'.
Any inputs on escape sequence will be highly appreciated.
Thanks,
Prabhu.This is some substitution done by the JDBC driver. I suggest you post this
to a JDBC group. Or, better, don't use "strange" characters in identifiers.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Prabhu" <prabhu_mpp@.lycos.com> wrote in message
news:C5537E35-83B0-4F74-880C-EBC51A95F8D2@.microsoft.com...
> HI All,
> I'm using SQL server 2000 and SQL Server JDBC driver to connect to it.
> I have a field name which has a ? in it. For eg field?
> In the query analyzer when i execute the following query
> select field? from qtable. It executes successfully. In the Java code
> I tried the same like ResultSet rs = stmt.executeQuery("Select field?
from qtable");
> The following exceptions was thrown [Microsoft][SQLServer 2000 Driver for

JDBC][SQLServer]Invalid column name 'field@.P1'.
> Any inputs on escape sequence will be highly appreciated.
> Thanks,
> Prabhu.|||Don't do Java anymore so can't try it, but have you tried something like
"select [field?] from qtable"?
"Prabhu" <prabhu_mpp@.lycos.com> wrote in message
news:C5537E35-83B0-4F74-880C-EBC51A95F8D2@.microsoft.com...
> HI All,
> I'm using SQL server 2000 and SQL Server JDBC driver to connect to it.
> I have a field name which has a ? in it. For eg field?
> In the query analyzer when i execute the following query
> select field? from qtable. It executes successfully. In the Java code
> I tried the same like ResultSet rs = stmt.executeQuery("Select field?
from qtable");
> The following exceptions was thrown [Microsoft][SQLServer 2000 Driver for

JDBC][SQLServer]Invalid column name 'field@.P1'.
> Any inputs on escape sequence will be highly appreciated.
> Thanks,
> Prabhu.|||Try enclosing the field name in square braces ie
select [field?] from qtable
Wayne Snyder MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
(Please respond only to the newsgroups.)
I support the Professional Association for SQL Server
(www.sqlpass.org)
"Prabhu" <prabhu_mpp@.lycos.com> wrote in message
news:C5537E35-83B0-4F74-880C-EBC51A95F8D2@.microsoft.com...
> HI All,
> I'm using SQL server 2000 and SQL Server JDBC driver to connect to it.
> I have a field name which has a ? in it. For eg field?
> In the query analyzer when i execute the following query
> select field? from qtable. It executes successfully. In the Java code
> I tried the same like ResultSet rs = stmt.executeQuery("Select field?
from qtable");
> The following exceptions was thrown [Microsoft][SQLServer 2000 Driver for

JDBC][SQLServer]Invalid column name 'field@.P1'.
> Any inputs on escape sequence will be highly appreciated.
> Thanks,
> Prabhu.|||Thanks alot for the responses, but the suggestion given did not solve the is
sue.Any other thoughts pls?
Seems to be JDBC related issue.
Thanks,
Prabhu

No comments:

Post a Comment