Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default SQL Syntax Error

I am querying an external database and get a syntax error message that looks
like:

SELECT CMT REGISTER_TRANSACTION.Bank_Account,
CMT_REGISTER_TRANSACTION.Check<<???, etc, etc.
FROM CMT_REGISTER_TRANSACTION CMT_REGISTER_TRANSACTION
WHERE (CMT_REGISTER_TRANSACTION.Bank_Account='4001')
Syntax Error.

The problem seems to be the "check" field because if I remove it, the data
is retrieved. Have checked the ODBC connections and also confirmed if there
are custom descriptions for the "check" field. Everything seems to be in
order. Have also tried querying other tables in the external database & have
no problems. Wondering what could be causing Excel to return a syntax error
message on this field.

Thanks,
Cheryl
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default SQL Syntax Error

Probably too simple an explanation but could it be that there's a field with
a name that starts with "Check" and has a space (e.g. "Check Box")? If so,
it will need square brackets around it, eg
SELECT CMT REGISTER_TRANSACTION.Bank_Account,
CMT_REGISTER_TRANSACTION.[Check Box], etc

"Cheryl" wrote:

I am querying an external database and get a syntax error message that looks
like:

SELECT CMT REGISTER_TRANSACTION.Bank_Account,
CMT_REGISTER_TRANSACTION.Check<<???, etc, etc.
FROM CMT_REGISTER_TRANSACTION CMT_REGISTER_TRANSACTION
WHERE (CMT_REGISTER_TRANSACTION.Bank_Account='4001')
Syntax Error.

The problem seems to be the "check" field because if I remove it, the data
is retrieved. Have checked the ODBC connections and also confirmed if there
are custom descriptions for the "check" field. Everything seems to be in
order. Have also tried querying other tables in the external database & have
no problems. Wondering what could be causing Excel to return a syntax error
message on this field.

Thanks,
Cheryl

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default SQL Syntax Error

If you are talking about SQL Server, CHECK is a reserved word, so if you have
a column in your table with that name, try using SELECT [Check] from...

Hope this helps.

--
urkec


"Cheryl" wrote:

I am querying an external database and get a syntax error message that looks
like:

SELECT CMT REGISTER_TRANSACTION.Bank_Account,
CMT_REGISTER_TRANSACTION.Check<<???, etc, etc.
FROM CMT_REGISTER_TRANSACTION CMT_REGISTER_TRANSACTION
WHERE (CMT_REGISTER_TRANSACTION.Bank_Account='4001')
Syntax Error.

The problem seems to be the "check" field because if I remove it, the data
is retrieved. Have checked the ODBC connections and also confirmed if there
are custom descriptions for the "check" field. Everything seems to be in
order. Have also tried querying other tables in the external database & have
no problems. Wondering what could be causing Excel to return a syntax error
message on this field.

Thanks,
Cheryl

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default SQL Syntax Error

Tried out your suggestion and altered the field name, but none worked. Also
ran a test thru Access, bringing in the same table to view the properties and
the field is called "check". Hmm, this one is a puzzle. Thanks a lot for
the suggestion and your time.

"Smallweed" wrote:

Probably too simple an explanation but could it be that there's a field with
a name that starts with "Check" and has a space (e.g. "Check Box")? If so,
it will need square brackets around it, eg
SELECT CMT REGISTER_TRANSACTION.Bank_Account,
CMT_REGISTER_TRANSACTION.[Check Box], etc

"Cheryl" wrote:

I am querying an external database and get a syntax error message that looks
like:

SELECT CMT REGISTER_TRANSACTION.Bank_Account,
CMT_REGISTER_TRANSACTION.Check<<???, etc, etc.
FROM CMT_REGISTER_TRANSACTION CMT_REGISTER_TRANSACTION
WHERE (CMT_REGISTER_TRANSACTION.Bank_Account='4001')
Syntax Error.

The problem seems to be the "check" field because if I remove it, the data
is retrieved. Have checked the ODBC connections and also confirmed if there
are custom descriptions for the "check" field. Everything seems to be in
order. Have also tried querying other tables in the external database & have
no problems. Wondering what could be causing Excel to return a syntax error
message on this field.

Thanks,
Cheryl

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default SQL Syntax Error

You have missed out the underscore on the first line:

SELECT CMT_REGISTER_TRANSACTION.Bank_Account,

MH

"Cheryl" wrote in message
...
I am querying an external database and get a syntax error message that
looks
like:

SELECT CMT REGISTER_TRANSACTION.Bank_Account,
CMT_REGISTER_TRANSACTION.Check<<???, etc, etc.
FROM CMT_REGISTER_TRANSACTION CMT_REGISTER_TRANSACTION
WHERE (CMT_REGISTER_TRANSACTION.Bank_Account='4001')
Syntax Error.

The problem seems to be the "check" field because if I remove it, the data
is retrieved. Have checked the ODBC connections and also confirmed if
there
are custom descriptions for the "check" field. Everything seems to be in
order. Have also tried querying other tables in the external database &
have
no problems. Wondering what could be causing Excel to return a syntax
error
message on this field.

Thanks,
Cheryl



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error - help Jim May Excel Discussion (Misc queries) 2 August 23rd 07 09:08 PM
runtime error: syntax error or access violation oucsester[_2_] Excel Programming 1 May 3rd 06 05:51 PM
runtime error: syntax error or access violation oucsester Excel Programming 0 May 3rd 06 02:22 PM
variable not declared error & syntax error G. Beard Excel Programming 1 October 6th 05 09:16 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 09:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"