If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Variables in sql select statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-24-04, 03:33
mossimo mossimo is offline
Registered User
 
Join Date: Nov 2003
Posts: 5
Exclamation Variables in sql select statement

Can you use a variable for the table name in a select statement?

The following code is working on the server but testing it on my server I get the error:
“(0x80040E14) Syntax error in query. Incomplete query clause.”

The variable “sTBL” is the table name. Am I writing bad code or could it just be that the variable “sTBL” is empty until runtime?


The Code:

sSQL = "SELECT AT_DIN, AT_TransID, AT_Amount FROM "& sTBL &" WHERE AT_DIN = '" & sDIN & "'"
Reply With Quote
  #2 (permalink)  
Old 03-25-04, 08:57
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Variables in sql select statement

Use reponse.write or whatever to write out the value of sSQL before you run it.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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