版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/admans/article/details/83657999
Use DataBaseName
/*开启Ad Hoc Distributed Queries组件
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
*/
Insert into tableName (col1,col2,col3,……) --字段不能含有主键
SELECT col1,col2,col3,……
from opendatasource
(
'SQLOLEDB',
'Data Source=192.168.0.1;User ID=dbuser;Password=123456'
).DataBaseName.dbo.tableName
WHERE [datetime]>'2016-11-01 15:00:18.663'
AND [datetime]<'2016-11-01 15:00:18.663'
/*关闭Ad Hoc Distributed Queries组件
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
*/