Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using tables in multiple databases

Status
Not open for further replies.

davejoyce

Programmer
Jun 26, 2000
29
0
0
US
Visit site
Is there a way to select data from a table in database a and insert into a table in database b. For use in archiving for instance. Each database has a seperate DSN.<br><br>&lt;CFQUERY NAME=&quot;GetStatusData&quot; DATASOURCE=&quot;Sites&quot;&gt;<br>INSERT INTO GeneralArchive.StatusSnapshot_tbl (SnapshotDate, Plant, week, status, statusdate)<br> SELECT #Now()#, plant, '1',<br>&lt;!--- #DateDiff(&quot;WW&quot;, Start_Date, Now())# + 1, ---&gt;<br> status, status_date<br> FROM&nbsp;&nbsp;checklist_tbl<br> where N1 &lt;&gt; 'C' <br> ORDER by plant<br>&lt;/cfquery&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp; <p>Dave Joyce<br><a href=mailto:DaveJoyce@hotmail.com>DaveJoyce@hotmail.com</a><br><a href= > </a><br>
 
Yes you simply do<br>&lt;cfoutput query=&quot;query1&quot;&gt;<br><br>&lt;cfquery&gt;<br>INSERT into table2 (column1)<br>VALUES(query1column1)<br>&lt;/cfquery&gt;<br><br>&lt;/cfoutput&gt;<br><br>In query1 just give your columns an alias so that they are not the same name as the table you are inserting into.<br><br> <p>Russ Michaels<br><a href=mailto:russ@satachi.com>russ@satachi.com</a><br><a href= Internet Development</a><br>For my personal book recommendations visit <br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top