Use two CFQUERYs:
<cfquery name="firstDSN" datasource="DSN01">
select name from [user]
</cfquery>
<cfquery name="secondDSN" datasource="DSN02">
<cfloop query="firstDSN">
insert into otheruser (name) values ('#firstDSN.name#')
</cfloop>
</cfquery>
this insert (secondDSN) is essentially the same, but should be faster than:
<cfloop query="firstDSN">
<cfquery name="secondDSN" datasource="DSN02">
insert into otheruser (name) values ('#firstDSN.name#')
</cfquery>
</cfloop>
Eric Roberts wrote:
> This is coming from a different datasource, so I need a way to use a cfquery
> resultset in the insert. I wish cfquery allowed one to specify a different
> datasource from within a query.
>
> Eric
>
>
> /*-----Original Message-----
> /*From: Ryan Stille [mailto:[EMAIL PROTECTED]
> /*Sent: Wednesday, October 15, 2008 4:49 PM
> /*To: cf-talk
> /*Subject: Re: Streamlining an insert
> /*
> /*This is how you'd do it with MySQL:
> /*
> /*INSERT INTO tablename (x,y,z) SELECT x,y,z FROM othertable
> /*
> /*If you are using MSSQL, I'm sure its something similar.
> /*
> /*-Ryan
> /*
> /*Eric Roberts wrote:
> /*>
> /*>
> /*> I have been trying to come up with a more streamlined way to update the
> /*> contents of a table with data that is coming from a different database.
> /*Is
> /*> there a way to use in the values clause a reverence to a record from a
> /*cf
> /*> query instead of actually typing out all of the variables? Something
> /*along
> /*> the lines of:
> /*>
> /*>
> /*>
> /*> Insert into table(x,y,z)
> /*>
> /*> Values(#queryname[currentrow]#)
> /*>
> /*>
> /*>
> /*> Or is there a way to use cfinsert or some other process where I could
> /*> essentially pass the query object so that I can insert the data without
> /*> having to loop and do each insert individually?
> /*>
> /*>
> /*>
> /*> Thanks!
> /*>
> /*>
> /*>
> /*> Eric
> /*>
> /*>
> /*>
> /*>
> /*>
> /*>
> /*>
> /*>
> /*>
> /*>
> /*>
> /*>
> /*
> /*
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313998
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4