[quoted text, click to view] "Massimo" <barone@mclink.it> wrote in message
news:O0LoNF$GIHA.4228@TK2MSFTNGP02.phx.gbl...
>I have an ASP (classic ASP) page which queries data from two databases
>residing on the same SQL Server 2005 instance; it takes advantage of this
>by using a query like this:
>
> SELECT Something FROM DB1.dbo.SomeTable
> UNION
> SELECT SomethingElse FROM DB2.dbo.SomeOtherTable
>
> The two tables have, of course, the same schema.
>
> The two databases are being moved to different instances, so this syntax
> is not going to work anymore.
Oh yes it can. You just make sure 1st server is aware of the 2nd servers
existence.
Then if you connect to the 1st server you specify the remote server in the
SELECT.
Result: You still get the the same recordset.
Nearly all the databases I know have a way of registering a remote server.
See SQL Server 2005 Books Online
You want to run the system SP:
sp_addlinkedserver
Creates a linked server, which allows access to distributed, heterogeneous
queries against OLE DB data sources. After creating a linked server with
sp_addlinkedserver, this server can then execute distributed queries. If the
linked server is defined as Microsoft® SQL ServerT, remote stored procedures
can be executed.
Syntax
sp_addlinkedserver [ @server = ] 'server'
[ , [ @srvproduct = ] 'product_name' ]
[ , [ @provider = ] 'provider_name' ]
[ , [ @datasrc = ] 'data_source' ]
[ , [ @location = ] 'location' ]
[ , [ @provstr = ] 'provider_string' ]
[ , [ @catalog = ] 'catalog' ]
Then afterwards
SELECT Something FROM DB1.dbo.SomeTable
UNION
SELECT SomethingElse FROM remoteserver.DB2.dbo.SomeOtherTable
Stephen Howe