jvosika
asked on
Duplicate an Access table entirely through code
Is there an easy way with Cold Fusion/SQL to copy a table's structure and datatypes, but not the information, to a new table with a new name?
Thank you!
Jim Vosika
http://www.wallclocksrus.com
Thank you!
Jim Vosika
http://www.wallclocksrus.com
Or may be u can try this also
create table New_table as select * from Old_Table where condition.....
Please let me know
Regards
Sandy
create table New_table as select * from Old_Table where condition.....
Please let me know
Regards
Sandy
ASKER
I tried both options and neither did it. For the second one here is my code:
<cfquery datasource="dbTest" name="createtable">
create table 12345 as select * from blank where id=1
</cfquery>
...and here is the error I get:
Error Occurred While Processing Request
Error Executing Database Query.
[MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in CREATE TABLE statement.
1 : <cfinclude template="header.cfm">
2 : <cfoutput>
3 : <cfquery datasource="dbTest" name="createtable">
4 : create table 12345 as (select * from blank where id=1)
5 : </cfquery>
<cfquery datasource="dbTest" name="createtable">
create table 12345 as select * from blank where id=1
</cfquery>
...and here is the error I get:
Error Occurred While Processing Request
Error Executing Database Query.
[MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in CREATE TABLE statement.
1 : <cfinclude template="header.cfm">
2 : <cfoutput>
3 : <cfquery datasource="dbTest" name="createtable">
4 : create table 12345 as (select * from blank where id=1)
5 : </cfquery>
try DTS in SQL - it shld do the job for u !
One thing you need to verify is in the CFAdmin make sure that you have the permissions set in your datasource to allow the creation of tables otherwise it will never work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this shall just clone the table without any data. :-)
ASKER
Perfect! That did the trick. Thank you all for your help.
into <other table name>
from <tablename>
where condition ......
make sure that th option 'select into/bulkinsert is enabled. Which you can do like this:
exec sp_dboption <databasename>, 'select into/bulkcopy', true