In linked server, which server will process data?

  • In ServerA, I created a linked server to ServerB.

    In ServerA, there is a query like below.

    select * from [ServerB].order.dbo.allorder where city='london'

    Question:

    Which server will process data?

    1) processing in B and then pass the result to A

    2) pass all data in A from B, process in A

  • In this scenario Server B processes it, then passes it back to Server A

    ______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience

  • MyDoggieJessie (4/10/2013)


    In this scenario Server B processes it, then passes it back to Server A

    i believe that's incorrect:

    i'm pretty sure this code, Executed on server A would copy the entire table allorder into temp, and then perform the WHERE statement , and then return the results.

    select * from [ServerB].order.dbo.allorder where city='london'

    this would do the work on ServerB:

    EXECUTE ( 'select * from order.dbo.allorder where city=''london'' ' ) AT ServerB;

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Is there any way to set up linked server always run in B without this statement?

    EXECUTE ( 'select * from order.dbo.allorder where city=''london'' ' ) AT ServerB;

  • adonetok (4/10/2013)


    Is there any way to set up linked server always run in B without this statement?

    EXECUTE ( 'select * from order.dbo.allorder where city=''london'' ' ) AT ServerB;

    Now that I'm thinking about it, the same command via OPENQUERY would perform at the remote as well: the problem with that is the same as EXECUTE AT: the query has to be hardcoded into a static string, no swapping with a variable like @sqlstatement

    SELECT * FROM OPENQUERY( [ServerB],'SET FMTONLY OFF; 'select * from order.dbo.allorder where city=''london''; ')

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • There is a very good write-up on this here

    ______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience

  • adonetok (4/10/2013)


    In ServerA, I created a linked server to ServerB.

    In ServerA, there is a query like below.

    select * from [ServerB].order.dbo.allorder where city='london'

    Question:

    Which server will process data?

    1) processing in B and then pass the result to A

    2) pass all data in A from B, process in A

    In addition to EXECUTE AT and OPENQUERY, you also have the REMOTE join hint, to instruct SQL Server to perform the join at the remote.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply