SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 14th, 2004, 02:00 PM
shirajr shirajr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 shirajr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Variable table name

Hi,

I've looked around on the forum to see if this has been answered before and couldn't find anything specific, but please be patient if it has been answered.

I'm reworking a set of queries that are used at my workplace to create periodic snapshots. The last step is a make-table query, and I'd like to be able to name the resulting table without changing the acutal SQL code, i.e.

SELECT ... INTO table_name_goes_here

I'm using Access (not my choice) and ideally would have the user enter the table name in a form.

Any ideas or suggestions?

Thanks

Reply With Quote
  #2  
Old June 14th, 2004, 02:41 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
What is wrong with Access. It can be very powerful in the right persons hands.


What you want to do is write VBA code that executes you SQL statement. You will pass your table name to the sql as a variable

Dim dbs As Database
Dim TableName as string
DIm SQL as string
Set dbs = CurrentDb()
TableName = "NewTable"
SQL = "Select * INTO " & TableName & " From OldTableName"
dbs.Execute SQL
dbs.Close


S-

Reply With Quote
  #3  
Old June 14th, 2004, 04:50 PM
shirajr shirajr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 shirajr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks

Thanks, that pointed me in the right direction.
I'm not trying to malign access, just so suggestions would only deal with Access.

Thanks for your help.

Reply With Quote
  #4  
Old November 12th, 2004, 10:45 PM
Deliriumxx Deliriumxx is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 Deliriumxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I seem to have a little problem too

I seem to have a problem that bugs me quite a lot and it is subject related.
I am requesting a Name for the table I need to create and it reports the error message when I use the variable in place of the TableName:

Syntax error in CREATE TABLE statement.

Here is the code:
CTBLName = Request.Form("TBOXName")

strSQLCreate = "CREATE TABLE" & CTBLName & "(ID AUTOINCREMENT,Column1 varchar,Column1 varchar,Column1 varchar,Column1 varchar)"

When The statement is without a variable:

strSQLCreate = "CREATE TABLE TableName (ID AUTOINCREMENT,Column1 varchar,Column1 varchar,Column1 varchar,Column1 varchar)"

There is no error message. I've been using variables before in this manner but not in place of a table name.

Can you please help me a bit?

Thank you.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Variable table name


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT