Sql

IanT

Registered User.
Local time
Today, 15:13
Joined
Nov 30, 2001
Messages
191
I am trying to copy data from a table then name the table with the Now() data. So each time the code is run a new table is created named with the date and time.

I have used this so far:

DoCmd.RunSQL ("SELECT * INTO datNow FROM xx")

Can anyone help!
 
Why not just use a query to get the date range you want rather than have loads of unnecessary (and pointless) tables?
 
Hello again,

Their is only two reason i would ever consider making tables.

1. If i was doing a complex query and couldn't find anyother way. As soon as i a had finished i would use the Drop sql statment and get rid of them.

2. when i wanted to archive hospital waiting list data that would be sent to an external body for verification and we needed a copy. The reason being the information changes on a daily basis and we needed a permanent snapshot once a month by law.

If as Mile suggests you simply want the data for a report, for example ,then use a query.

Any way this is the how to create a table in SQL. I seriously suggest you consider the reasons why you are doing this.


Code:
DoCmd.RunSQL("SELECT MyOldTable.*, INTO TBL_" & Date() & " FROM MyOldTable" &  _
" WHERE (((MyOldTable.MyDateField) Between #12/12/2003# And #1/12/2004#));")

' MyOldTable And MyDateField are the names of your table and a field containing dates that you wish to use as a filter.


for a straight copy

Code:
DoCmd.RunSQL("SELECT MyOldTable.* INTO TBL_" & Date() & " FROM MyOldTable;")

TS
 

Users who are viewing this thread

Back
Top Bottom