문제

I have a very simple script. The purpose is to pull data from a linked server into a table in another database

DECLARE @SQLString VARCHAR(2000)

SET @SQLString = 'SELECT * from OPENQUERY(MyLinkedServer, 
    ''SELECT 
    ...
    ...
    FROM SomeSchema.SomeTable'')'

INSERT INTO MySchema.MyTable
            (
              ............
            )
            EXEC(@SQLString)

In what fashion is this executed? If I just set up the @SQLString and EXEC, results will be displayed to my screen. Does this mean that running the script above will bring the data from the linked server to my local machine, then off to my sql server database, or does the data go straight from my linked server to sql server?

도움이 되었습니까?

해결책

The data always goes from the linked server to the SQL Server before going to the client (if applicable), as shown in the documentation for both distributed queries and linked servers. Since your client is only connected to SQL Server, not directly to the linked server, this is the only way it could work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top