Skip to Content.
Sympa Menu

freetds - [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: Andy Cranston <a.cranston AT selwaymoore.com>
  • To: "'freetds AT lists.ibiblio.org'" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Msg 170 Incorrect Syntax - could this be caused by odd characters in the table name?
  • Date: Thu, 1 Apr 2004 12:04:14 +0100

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
________________________________________________________________________




Archive powered by MHonArc 2.6.24.

Top of Page