OK... For cross servers we need to link the two
servers which can be done through enterprise manager
or through QA also:
EXEC sp_addlinkedserver SERVER_01
GO
/* The following command links 'sa' login on SERVER_02
with the 'sa' login of SERVER_01 */
EXEC sp_addlinkedsrvlogin @rmtsrvname = 'SERVER_01',
@useself = 'false', @locallogin = 'sa', @rmtuser =
'sa', @rmtpassword = 'sa password of SERVER_01'
GO
SELECT a.title_id
FROM SERVER_01.pubs.dbo.titles a
INNER JOIN SERVER_02.pubs.dbo.titles b
ON a.title_id = b.title_id
GO
Reg
San
(courtsey: vyas)
--- Aman Bharat Sharma <[Email Address Removed] wrote:
> Hi Nirmal,
>
> ur query is
>
> 1. Cross database
> select a.col_name ,*
> from pubs..anytable a join northwind..anytable1 b
> as "ur condition"
>
> 2. Cross server
>
> select a.col_name
> from server1.pubs..anytable a join
> server2.northwind..anytable1 b as "ur
> condition"
>
> for cross server queries u need to link bothe
> databases, u can do this
> by starting enterprise manager
>
> go to server name>security> linked servers
>
> it'll guide u from there .
>
> Gurus do correct me if i m wrong somewhere , as i m
> new to the DBA world.
>
> Aman
>
>
> -----Original Message-----
> From: Nirmal C.Kumar [mailto:[Email Address Removed] Sent: Thursday, January 30, 2003 5:06 PM
> To: LazyDBA.com Discussion
> Subject: query between 2 servers/databse
>
>
> List
>
>
> Can you help me to figure out how to go in writing a
> query a select or a
> insert combining 2 tables from more than 1 database
> .What's the syntax .
>
> For example :
>
> 1. I need to write a select for a table joining a
> table from a pubs and
> northwind .
>
> 2. How can I combine a single query from 2 database
> server .
>
> Nirmal
>
>
>
>
---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT
> JUST REPLY
> To unsubscribe, e-mail:
> mssqldba-[Email Address Removed] For additional commands, e-mail:
> mssqldba-[Email Address Removed]
>
---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT
> JUST REPLY
> To unsubscribe, e-mail:
> mssqldba-[Email Address Removed] For additional commands, e-mail:
> mssqldba-[Email Address Removed]
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
MS Sql Server LazyDBA home page