Skip to Content.
Sympa Menu

freetds - Re: Handling of Sybase column names

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Eric Deutsch" <edeutsch AT systemsbiology.org>
  • To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Handling of Sybase column names
  • Date: Tue, 29 Jan 2002 18:13:16 -0800



I'm not sure about Sybase (in fact, I'm curious, does it work??), but MS SQL
Server 2000 also allows the notation where []'s surround database objects:

SELECT [Date] FROM [Table]

This is not dependent on QUOTED_IDENTIFIER.

In fact, it would appear that this is preferred syntax for MSSQL. As far as
I can tell, auto-generated SQL by SQL Server tools always use []'s (for
example, click on a table in Enterprise Manager, [Copy], and then [Paste]
into notepad or some such, and you'll see the autogenerated CREATE TABLE
statement with all objects inside []'s). Of course this may be totally
unportable, and a way for MS keep the lobsters in the pot.


> From: Brian Bruns
>
> FreeTDS does not manipulation of the SQL text prior to sending it to the
> server, except in the case of TDS 7.0 an ascii string is converted to
> unicode when submitted. The content is not changed however.
>
> you may want to try something like
>
> SELECT "Date" from "Table"
>
> and there is a way to turn strict ansi compliance on (escapes me at the
> moment). But long story short, ANSI defines " and ' as different
> things.
> ' (single quote) is used for string literals whereas " (double quote) is
> used for identifiers such as tables/columns with spaces in them, eg
> SELECT "My Column" FROM "My Table With Spaces in the Name"
>
> So double quotes with ansi compliance turned on may work.
>
> Brian
>
> On Tue, 29 Jan 2002, Shrock, Court wrote:
>
> > Here is my problem:
> >
> > The database that I need to access has table names that are normally
> > reserved--ie, "Date", "Bit", etc...I would like to be able to
> pass the query
> > "SELECT Date FROM Events" or "SELECT * FROM Events ORDER BY
> Date", but the
> > response acts as though it thinks Date is a function (I know
> one does exist,
> > but I want to refer to the column name, not the function). I know this
> > because I get an error about wrong number of parameters with the query
> > "SELECT Date() FROM Events". Any ideas?
> >
> > Does freetds do any manipulating of the query string before it
> sends it to
> > the server listed in the freetds.conf?
> >
> > I can "SELECT * FROM Events" and the Date column is returned,
> but my problem
> > is that how can one include reference to "Date" in the WHERE, GROUP, and
> > ORDER portions of the query? Incidently, the "SELECT * FROM
> Events" returns
> > the data that I need--connectivity is not a problem.
> >
> > I am accessing the database via PHP-4.1.1/freeTDS-0.53 on linux-2.2.19.
> >
> > Many thanks,
> > Court
> >
> >
> > ---
> > You are currently subscribed to freetds as: [camber AT ais.org]
> > To unsubscribe, forward this message to
> $subst('Email.Unsub')
> >
>
>
> ---
> You are currently subscribed to freetds as: [edeutsch AT systemsbiology.org]
> To unsubscribe, forward this message to
> $subst('Email.Unsub')
>





Archive powered by MHonArc 2.6.24.

Top of Page