mssql sqlserver 使用链接服务器查询sql脚本时候,出现7399错误的处理方法


摘要:
今天使用链接服务器运行sql脚本,提示7399错误
下文将详细解释处理此异常的方法


解决方法:
1.链接服务器是否正常

  
EXEC master.dbo.sp_addlinkedserver @server = N'192.168.1.182', @srvproduct=N'SQL Server' 

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'192.168.1.182',@useself=N'False',@locallogin=NULL,@rmtuser=N'sa',@rmtpassword='sa_password'

GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'collation compatible', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'data access', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'dist', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'pub', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'rpc', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'rpc out', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'sub', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'connect timeout', @optvalue=N'0'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'collation name', @optvalue=null
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'lazy schema validation', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'query timeout', @optvalue=N'0'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'use remote collation', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'192.168.1.182', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO
   

2.当前数据库进行下列设置

    use master
	GO
	exec sys.sp_configure 'show advanced options',1
	reconfigure with override 
	GO
	exec sys.sp_configure 'Ad Hoc Distributed Queries',1
	GO
	reconfigure with override 
	GO
   

3.再次测试是否可正常运行