SQL Server - Copy table across databases

  • 在目标数据库上运行配置
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
  • 执行拷贝
INSERT INTO [DEV].[dbo].[tblDest]
   ([ID]
   ,[Name])
SELECT
    *
FROM
    OPENDATASOURCE('SQLOLEDB', 'Data Source=192.168.1.103,3422;User ID=sa;Password=YourPWD;').databaseName.dbo.tblSource