Skip to Content.
Sympa Menu

freetds - RE: [freetds] Msg 170 Incorrect Syntax - could this be caused by odd characters in the table name?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Msg 170 Incorrect Syntax - could this be caused by odd characters in the table name?
  • Date: Thu, 1 Apr 2004 13:55:28 +0100

Hi Andy,

Fairly simple this...

see SET QUOTED_IDENTIFIER In SQl server books online.

When SET QUOTED_IDENTIFIER is ON, identifiers can be delimited by double
quotation marks...
When SET QUOTED_IDENTIFIER is OFF, identifiers cannot be quoted....
...
The SQL Server ODBC driver and Microsoft OLE DB Provider for SQL Server
automatically set QUOTED_IDENTIFIER to ON when connecting
SET QUOTED_IDENTIFIER defaults to OFF for connections from DB-Library
applications.
...

we default to the ODBC behaviour, but this is turned off when you connect by
db-library

if you want to persist with your table names, you'll have to explicitly
issue a "SET QUOTED_IDENTIFIER ON" once you have connected to the server...

HTH,

Bill

> -----Original Message-----
> From: Andy Cranston [SMTP:a.cranston AT selwaymoore.com]
> Sent: 01 April 2004 12:04
> To: 'freetds AT lists.ibiblio.org'
> Subject: [freetds] Msg 170 Incorrect Syntax - could this be caused by
> odd characters in the table name?
>
> Hello list,
>
> After successfully compiling the dblib t001.c unit test program I am now
> on
> the next stage of building my own C program to query a SQL Server 8.0
> database.
>
> I am trying to select three columns from a table based on a part
> identifier
> number. Here is the output of the program:
>
> $ ./csq A4800A
> select "Description","Manufacturer Code","Item Category Code"
> from "TEST SML$Item" where ("No_" = 'A4800A')
> Msg 170, Level 15, State 1
> Server 'BUSSYS', Line 1
> Line 1: Incorrect syntax near 'TEST SML$Item'.
> ./csq: part identifier lookup gave incorrect number of columns
> $
>
> So my syntax is wrong? Ok - so this is a tsql transcript to the same
> server:
>
> $ tsql -S BUSSYS -U dbreadonly
> locale is "C"
> locale charset is "646"
> Password:
> Msg 5703, Level 0, State 1, Server BUSSYS, Line 0
> Changed language setting to us_english.
> 1> use Test
> 2> go
> 1> select "Description","Manufacturer Code","Item Category Code"
> 2> from "TEST SML$Item" where ("No_" = 'A4800A')
> 3> go
> Description Manufacturer Code Item Category Code
> PCI FWD SCSI2 Interface Card HP MISC
> 1> exit
> $
>
> This works perfectly.
>
> The only thing I can think of is that the table name:
>
> TEST SML$Item
>
> contains a space and a $ (dollar) character. Could this be the cause of
> the
> syntax error and, if so, why does running the same query via tsql work
> when
> submiting the query via my C program does not?
>
> Any help gratefully received.
>
> I can post the C code to the list if necessary or email it to any kind
> individuals who can help me out.
>
> Regards,
>
> Andy Cranston.
>
> ________________________________________________________________________
> This message has been checked for all known viruses by the Selway Moore
> scanning service powered by MessageLabs. For further information and
> statistics on current viruses visit http://www.messagelabs.com/stats.asp
> ________________________________________________________________________
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds

==============================================================================

If you are not an intended recipient of this e-mail, please notify
the sender, delete it and do not read, act upon, print, disclose,
copy, retain or redistribute it.

Click here for important additional terms relating to this e-mail.
<http://www.ml.com/email_terms/>

==============================================================================




  • RE: [freetds] Msg 170 Incorrect Syntax - could this be caused by odd characters in the table name?, Thompson, Bill D (London), 04/01/2004

Archive powered by MHonArc 2.6.24.

Top of Page