Re: how to connect to multiple database mssql?
- From: "Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom>
- Date: Thu, 18 May 2006 13:46:18 +0100
can you make an exaple with sql server?
i have these 2 connection string:
You don't need 2 connection strings. You need 1 connection string.
It is provider that does the work _NOT_ ADO
All that matters is whether
(i) both databases are on same server
(ii) databases are on different servers
In the case of (i), with 2 databases called fred, gladys
- get a connection, using one of the databases
- populate a recordset or similar with something like
SELECT f.field1,g.field2 FROM
fred.dbo.table1 f JOIN gladys.dbo.table2 g ON f.field3=g.field4
WHERE ...
ORDER BY 1,2
and SQL Server will do what is join 2 tables from 2 different databases that
it is managing.
In the case of (ii), you need to run the Stored Procedure sp_addlinkedserver
on Query Analyser first so that one server is aware of the 2nd server's
existence
See http://msdn2.microsoft.com/en-us/library/ms190479.aspx
call it server2
and then after that it is similar.
SELECT f.field1,g.field2 FROM
fred.dbo.table1 f JOIN server2.gladys.dbo.table2 g ON f.field3=g.field4
WHERE ...
ORDER BY 1,2
Stephen Howe
connStr1,connStr2
and this query to do:
"SELECT title FROM conn1.dbo.tableTitleHolder UNION ALL select title
FROM conn2.dbo.tableTitleHolder WHERE..."
i've tryed sqlConnection(connStr1+","+connStr2),
but i get an error
.
- References:
- how to connect to multiple database mssql?
- From: cipcip
- Re: how to connect to multiple database mssql?
- From: Stephen Howe
- Re: how to connect to multiple database mssql?
- From: cipcip
- how to connect to multiple database mssql?
- Prev by Date: Re: Record Count from Data Reader
- Next by Date: Re: what's wrong with this?
- Previous by thread: Re: how to connect to multiple database mssql?
- Next by thread: Re: Error registering when installing MDAC
- Index(es):
Relevant Pages
|
|