Make Table Dynamic Table Name using INTO

  • Thread starter Thread starter excelCPA
  • Start date Start date
E

excelCPA

Is there a way to write a Make Table query with dynamic table name?

For example, I want my query to make a table titled Results_MMDDYY,
where the MMDDYY is fully dynamic based on the date that I run the
query.

SELECT USER_ID, LOGIN_DATE, INTO [Results_]& Now()

The above line of SQL doesn't execute, but is there a way to do this
in the SQL editor (not in VBA)?
 
excelCPA said:
Is there a way to write a Make Table query with dynamic table name?

For example, I want my query to make a table titled Results_MMDDYY,
where the MMDDYY is fully dynamic based on the date that I run the
query.

SELECT USER_ID, LOGIN_DATE, INTO [Results_]& Now()

The above line of SQL doesn't execute, but is there a way to do this
in the SQL editor (not in VBA)?

No.
You have to use VBA to dynamically create the sql.
 
Is there a way to write a Make Table query with dynamic table name?

For example, I want my query to make a table titled Results_MMDDYY,
where the MMDDYY is fully dynamic based on the date that I run the
query.

SELECT USER_ID, LOGIN_DATE, INTO [Results_]& Now()

The above line of SQL doesn't execute, but is there a way to do this
in the SQL editor (not in VBA)?

No. You'll need to actually construct the SQL string and then execute it.

Note that this would be a HORRIBLE idea - storing data in a tablename is very
bad design. It's not searchable, it bloats your database, and it's
unnecessary; you could and should instead store the data in a table with a
datefield and use a Query to dynamically select any day's subset of the data.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
Back
Top