Sql--------服务器的数据库表数据插入到本地数据库

本地语句:::insert into 表名(列名) SELECT * FROM OPENDATASOURCE('SQLOLEDB', 'Data Source=127.0.0.1;User ID=sa;Password=123456').服务器数据库名.表名

执行上述语句之前一定要配置一个组件

执行语句如下:

开启方法:

exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

关闭方法

exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
否则会报如下错误

SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问

原文地址:https://www.cnblogs.com/LMJBlogs/p/7856205.html