For example - if you have 3 different installations of an ap with three
different user databases and you wanted to build a single interface for all
three (like a master administrators db) -  you could create a user on the MS
SQL server with permissions to all three.  Then, using a DSN with that USER
You could then run a query like this:

<cfquery name="user" datasource="#application.admindsn#">
        SELECT A.username, A.password, 'DB_A' as Datasource
        FROM    DbnameA.dbo.Users
        UNION
        SELECT B.username, B.password, 'DB_B' as Datasource
        FROM    DbnameB.dbo.Users
        UNION
        SELECT C.username, C.password, 'DBC' as Datasource
        FROM    DbnameC.dbo.Users
        order by Datasource
</cfquery>

This would give you all the users from all three databases

It is also possible to do similar things in Access by specifying the file
path to the second datasource.... I had a sample of that once but its fallen
by the wayside.

Obviously there is a security issue here - 1 username with permissions on 3
databases... so make sure you have thought it all through.

-------------------------------------------------------


-----Original Message-----
From: Robertson-Ravo, Neil (RX)
[mailto:[EMAIL PROTECTED]
Sent: Monday, May 09, 2005 8:25 AM
To: CF-Talk
Subject: RE: More than one datasource in <cfquery>


Yep basically the format is database.owner.table.column

So you could do SELLECT * FROM EmployeeDirectory.dbo.Employee



-----Original Message-----
From: Adam Haskell [mailto:[EMAIL PROTECTED]
Sent: 09 May 2005 14:27
To: CF-Talk
Subject: Re: More than one datasource in <cfquery>

If you use MS SQL you can use Linked Servers to query across different
servers. it would be something like:

Select *
>From myLink.database.owner.table


Adam H





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206052
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to