Insert Data From One Server To Another?

后端 未结 3 530
梦毁少年i
梦毁少年i 2020-12-06 07:20

If I want to run this sort of query in SQL Server, how can I do the same query from one server I am connected to to another?

I tried adding \"[ServerName1].\" before

3条回答
  •  没有蜡笔的小新
    2020-12-06 07:46

    If you have adhoc distributed queries enabled you can use OPENDATASOURCE. Setting up a linked server is another option. Not sure of the pros and cons of each approach.

    INSERT INTO [DatabaseName1].[dbo].[TableName]
    SELECT FieldName
    FROM OPENDATASOURCE('SQLNCLI',
        'Data Source=Server\InstanceName;Integrated Security=SSPI')
        .DatabaseName2.dbo.TableName
    

提交回复
热议问题