SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 2 server used in 1 query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Villanuev
Constraint Violating Yak Guru

309 Posts

Posted - 05/23/2012 :  23:24:43  Show Profile  Reply with Quote
Hi Forumer’s

I would like to create an script that will use 2 server. The first table tableA is stored in server1 and tableB stored in sever2. Is this possible? what are the requirements. Kindly please help me guys on how to do this.


thanks in advance.


jov

yosiasz
Flowing Fount of Yak Knowledge

USA
1608 Posts

Posted - 05/23/2012 :  23:46:01  Show Profile  Click to see yosiasz's MSN Messenger address  Reply with Quote
yes it is possible

1. Use ssis or
2. use linked servers

These are the options that I know of

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

mani_12345
Starting Member

India
35 Posts

Posted - 05/24/2012 :  00:04:41  Show Profile  Reply with Quote
heii...
I am not sure about this but i guess the solution for this prbm will be :

for this you have to create one field in Server1 table that points to the server2 i.e Server2 name and then try to get information ..
Just thought for this have not tried yet...

Go to Top of Page

Villanuev
Constraint Violating Yak Guru

309 Posts

Posted - 05/24/2012 :  03:55:57  Show Profile  Reply with Quote
Thank you guys for the reply.

@yosiasz
I think the option #2,
But how could i do this?

sample: I have to get some information from table2 under server2 using the table1 under server1.

SERVERNAME: SERVER1
DBNAME: SAMPLEDB1
TABLE: TABLE1
--------------------
SERVERNAME: SERVER2
DBNAME: SAMPLEDB2
TABLE: TABLE2





Edited by - Villanuev on 05/24/2012 03:57:39
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 05/24/2012 :  16:01:43  Show Profile  Reply with Quote
quote:
Originally posted by Villanuev

Thank you guys for the reply.

@yosiasz
I think the option #2,
But how could i do this?

sample: I have to get some information from table2 under server2 using the table1 under server1.

SERVERNAME: SERVER1
DBNAME: SAMPLEDB1
TABLE: TABLE1
--------------------
SERVERNAME: SERVER2
DBNAME: SAMPLEDB2
TABLE: TABLE2







see how to add a linked server here

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=164892

once this is then the you can simply use a query like below
(assuming linked server is created in SERVER1 for SERVER2)


USE [SAMPLEDB1]
GO

SELECT *
FROM dbo.TABLE1 t1
INNER JOIN [SERVER2].[SAMPLEDB2],[dbo].TABLE2
ON...


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Villanuev
Constraint Violating Yak Guru

309 Posts

Posted - 05/24/2012 :  21:28:53  Show Profile  Reply with Quote

Hi Visakh, Thank you very much for this very informative info.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 05/25/2012 :  10:10:09  Show Profile  Reply with Quote
you're welcome

courtesy: Kristen

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000