SQL SERVER 2012/20​14 鏈接到 SQL SERVER 2000的解決方案

2017-08-09 19:51:00
瀟湘隱者
轉貼
1351


SQL SERVER 2012/2014 鏈接到 SQL SERVER 2000的解決方案


作者:瀟湘隱者


本文總結一下SQL SERVER 2012/2014鏈接到SQL SERVER 2000的各種坑,都是在實際應用中遇到的疑難雜癥。可能會有人説怎麽還在用SQL SERVER 2000,爲什麽不陞級呢? 每箇公司都會有一兩箇幾乎快被人遺忘的繫統,接手維護這些繫統的人可能都不知換瞭多少批瞭。牠們的命運註定慢慢消亡。然而偏偏卻又生命力頑強,總還有一些人在使用著這些繫統。所以就處在一種尷尬的境地: 陞級吧,價值不大,可能再過一兩年,這繫統就要被其牠繫統替代瞭。而且項目經理也沒有精力、人手耗費在這上麵。最重要的是擔心風險問題。因爲接手維護的人對這些繫統都不甚瞭解。如果貿然陞級,可能風險很大。

1:SQL Server Native Client 11.0 does not support connections to SQL Server 2000 or earlier versions

    自SQL Server 2012開始,已經不支持通過鏈接服務器鏈接到SQL Server 2000。主要是SQL SERVER 2012/2014安裝的是SQL Server Native Client 11.0。而SQL Server Native Client 11.0 does not support connections to SQL Server 2000 or earlier versions。關於這箇官方文檔

已有説明,具體如下所示:

This topic discusses how various data-access components can be used with SQL Server Native Client.

Server Support

SQL Server Native Client 11.0 supports connections to SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, and Windows Azure SQL Database.

Supported Operating System Versions

The following table lists which operating systems support SQL Server Native Client.

SQL Server Native Client version

Supported operating systems

SQL Server Native Client (SQL Server 2005)

  • Microsoft Windows 2000 Service Pack 4 or later
  • Microsoft Windows Server 2003 or later
  • Microsoft Windows XP Service Pack 1 or later
  • Microsoft Windows Vista (requires SQL Server Service Pack 2, or later)
  • Microsoft Windows Server 2008 (requires SQL Server Service Pack 2, or later)

SQL Server Native Client 10.0 (SQL Server 2008)

  • Microsoft Windows Server 2003 Service Pack 2, or later
  • Microsoft Windows XP Service Pack 2, or later
  • Microsoft Windows Vista
  • Microsoft Windows Server 2008

SQL Server Native Client 10.5 (SQL Server 2008 R2)

  • Microsoft Windows Server 2003 Service Pack 2, or later
  • Microsoft Windows XP Service Pack 2 or later
  • Microsoft Windows Vista
  • Microsoft Windows Server 2008
  • Microsoft Windows 7

SQL Server Native Client 11.0 (SQL Server 2012)

  • Microsoft Windows Vista
  • Microsoft Windows Server 2008
  • Microsoft Windows 7
  • Microsoft Windows 8
  • Microsoft Windows Server 2012

此時需要安裝SQL Server Native Client 10. 我在這篇文章SQL SERVER 2012鏈接到SQL SERVER 2000的問題解決案例裡麵介紹瞭如何安裝SQL Server Native Client 10

 

2: 卽使安裝瞭SQL Server Native Client 10,依然不能使用下麵常規的建立鏈接服務器的方法建立

EXEC master.dbo.sp_addlinkedserver @server = N'server_name', @srvproduct=N'SQL Server'
 
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'server_name',@useself=N'False',@locallogin=NULL,@rmtuser=N'username',@rmtpassword='########'
 
GO

 

3:以下麵方式建立鏈接服務器,能夠成功創建鏈接服務器,測試鏈接也OK,似乎一切OK

EXEC master.dbo.sp_addlinkedserver @server = N'server_name', @srvproduct=N'SQLSERVER', @provider=N'SQLNCLI10', @provstr=N'DRIVER={SQL Server Native Client 10.0};SERVER=192.168.xxx.xxx;'
 
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'server_name',@useself=N'False',@locallogin=NULL,@rmtuser=N'username',@rmtpassword='########'
 
GO

但是在調用鏈接服務器時,就會齣現下麵錯誤。

Msg 7399, Level 16, State 1, Line 1

The OLE DB provider "SQLNCLI10" for linked server "xxxxx" reported an error. Access denied.

Msg 7301, Level 16, State 2, Line 1

Cannot obtain the required interface ("IID_IDBCreateCommand") from OLE DB provider "SQLNCLI10" for linked server "xxxxx".

配置

 

4: OpenDataSource  SQL Server Native Client 11.0 does not support connections to SQL Server 2000

如果代碼裡麵有使用OpenDataSource,那麽就會報上麵的錯誤。此時必鬚修改爲鏈接服務器方式訪問。

 

 

SQL SERVER 2012/2014正確鏈接到SQL SERVER 2000的方法,

EXEC master.dbo.sp_addlinkedserver @server = N'Server_Name', @srvproduct=N'sqlserver', @provider=N'MSDASQL', @provstr=N'DRIVER={SQL Server Native Client 10.0};SERVER=192.168.xxx.xxx;'
 
 
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'Server_Name',@useself=N'False',@locallogin=NULL,@rmtuser=N'UserName',@rmtpassword='########'
 
GO

 

蔘考資料:

https://social.msdn.microsoft.com/Forums/en-US/7352802d-5294-45e1-999e-8749a38952eb/linked-server-sql-2012-to-2000-error-microsoft-distributed-transaction-coordinator-ms-dtc-has?forum=sqldatabaseengine

https://connect.microsoft.com/SQLServer/feedback/details/731869/using-sqlncli10-to-create-a-linked-server-to-sql-server-2000-causes-a-fault

https://msdn.microsoft.com/en-us/library/cc280356(v=SQL.110).aspx

分享