mssql 本地数据导入远程数据库和从远程数据库导出
本地数据导入远程服务器数据库。
insert into OPENROWSET
('SQLOLEDB', 'uid=a0307;pwd=430;Network=DBMSSOCN;Address=202.16.219.92,1433;',
'select [Week]
,[Jiont]
,[Content]
,[baseinfo_Id] from [Curricula]')
select [Week]
,[Jiont]
,[Content]
,[baseinfo_Id] from [Kebiao2].[dbo].[Curricula]
从远程数据库导出:
select Speciaty,ClassGrade
into [Kebiao2000].[dbo].BaseInfoes2 from OPENROWSET
('SQLOLEDB', 'uid=a03087;pwd=44330;Network=DBMSSOCN;Address=202.6.19.92,1433;',
'select [Speciaty]
,[ClassGrade] from [BaseInfoes]')
这样就可以,但要保证本地客户端连的上远程数据库。
可能会遇到一个错误
SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,
因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。
启用Ad Hoc Distributed Queries的方法,具体如下:
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

浙公网安备 33010602011771号