简体   繁体   中英

How to copy data from a view of one server into the database table of another server in a SQL server database?

how can i copy data from a view of one server into the database table of another server in a SQL server database without using linked servers method. I tried using the code:

SELECT [LogEntryID]
      ,[TimeStamp]
      Into [server-2].[database1].[dbo].[table1]
  FROM [server-1].[database1].[dbo].[view_1] 

I recieve the error " The object name 'server-2.database1.dbo.table1' contains more than the maximum number of prefixes. The maximum is 2. The copying statement i am using in a groovy code. But for first i am trying it in a query if it works.

You can use opendatasource instead of linked server

insert DestinationTable
select * from opendatasource('SQLOLEDB', 'Server=SourceServer;User Id=Username;Password=Password;').SourceDb.Schema.SourceTable;

OPENDATASOURCE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM