May 13, 2014 at 10:21 am
Hi
I am a newbie to sql server so please help me!
Say I have to server, A and B.
Now I want to write a stored procedure in server A, to retrive data from server B.
How could I manage to do that?
Thousands thanks in advance!
May 13, 2014 at 10:23 am
generally, you create a linked server.
then your procedure calls the four part name of the object on the other server,
like this:
SELECT ID,ColumnList FROM FinanceServer.FinDatabase.dbo.ProductsSoldTable
Lowell
May 13, 2014 at 11:10 am
Depending on the process it might be more efficient to perform joins, apply filters and/or aggregate data on the "source server" (Server A), e.g. by writing a stored procedure on Server A to provide the results based on input values and then just call the sproc from server B.
Especially when dealing with joins between (filtered) data located on different servers it might provide a performance gain to load the data from the source server to the target server into an indexed temp table.
May 13, 2014 at 8:04 pm
Use openrowset
[Code]
SELECT a.*
FROM OPENROWSET('SQLNCLI', 'Server=Seattle1;Trusted_Connection=yes;',
'SELECT GroupName, Name, DepartmentID
FROM AdventureWorks2012.HumanResources.Department
ORDER BY GroupName, Name') AS a;
[/Code]
May 13, 2014 at 9:56 pm
Thx for everyone's reply. I have learned a lot.
I eventually solve that by use synonymy, which provides the advantage for dealing future changes in source table.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply