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 > Dynamic generation of table name

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-22-06, 13:26
KamenG KamenG is offline
Registered User
 
Join Date: Dec 2005
Posts: 69
Question Dynamic generation of table name

I have a database that has some of its tables created at run-time, i.e., a table name is computed by a program and then the table is created, and the data - written to it. My program will have no trouble finding those tables but the end users will want to run queries using a DBMS client of their choice. They may simply want us to write them some predefined queries that they can execute in MSQuery to build Excel spreadsheets, or something like that.
My question is: is it possible to put in the FROM clause of a SELECT statement anything other than a string describing the name of a table in the database, and more specifically, a sub-query? Let's say I have a table with a known name that contains two columns, and I want to use the concatenation of the contents of those two columns to build the names of some tables, which will then be used in the FROM clause of another SELECT statement. Is that possible and how can I do that? Thanks in advance!
Kamen
Reply With Quote
  #2 (permalink)  
Old 03-22-06, 17:09
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool


For end-users: NO, for Developers you can use dynamic SQL.
Maybe for the end-users you could create a synonym for these tables, for example: every time you create a new table, you could drop old synonym and create new pointing to new table.

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 03-23-06, 10:20
KamenG KamenG is offline
Registered User
 
Join Date: Dec 2005
Posts: 69
Bummer... That's what I thought, looking at the SQL documentation. I guess they can always use some "programmable" client, such as MS Access. Thanks, anyway.
Kamen
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