kaarthick raman
kaarthick raman

Reputation: 839

Transfer/Access table values from one database server to another

I am using SQL SERVER 2012.

I have a stored procedure where i create a temporary table called RESULT which carries result-set of an inner-join.

     SELECT column(s)
     FROM [database1].[table1]
     INNERJOIN
     [database2].[table2]

The result-set is processed from tables in DB SERVER 1.

Now,I have to insert the result set inside another table present in DB SERVER 2.

Select * from [server2].[Table1].dbo.User WHERE UserID = Result.UserID

How to access the database of Server2 table from Server1 table?

Upvotes: 0

Views: 24

Answers (1)

TaylorN
TaylorN

Reputation: 399

I would say the easiest option would be to use a linked server (https://msdn.microsoft.com/en-au/library/ff772782.aspx)

Then you can query the server using

SELECT * 
FROM [SERVER].[DATABASE].[SCHEMA].[TABLE] t1
INNER JOIN [DATABASE2].[TABLE2] t2 ON t1.id = t2.id

Upvotes: 1

Related Questions