Link to home
Start Free TrialLog in
Avatar of ARSSE
ARSSE

asked on

SQL Server 2005 Linked Server and Mirroring issue

Hi,

I have a DB 'NCAccounts' which is mirrored (Principal and Mirror in two separate servers).  I have yet another DB in a 3rd server.  In the 3rd server, I created a Linked Server as follows to connect to 'NCAccounts':
---------------------------------------------------------------
--Create Linked Server
EXEC master.dbo.sp_addlinkedserver @server = N'MyLinkedServer',
@srvproduct=N'.', @provider=N'SQLNCLI',
@provstr=N'Server=DBASE-1;Partner=DBASE-2',
@catalog=N'NCAccounts'

--Create login for linked server
EXEC master.dbo.sp_addlinkedsrvlogin
@rmtsrvname=N'MyLinkedServer',@useself=N'False',@locallogin=N'Admin',@rmtuser=N'Admin',@rmtpassword=N'adminpwd'
---------------------------------------------------------------

The linked server was created, but on executing
"select * from MyLinkedServer.master.dbo.sysdatabases", the following error message was displayed:

---------------------------------------------------------------
Msg 18456, Level 14, State 1, Line 1
Login failed for user 'DBASE-1\admin'.
Msg 4060, Level 11, State 1, Line 1
Cannot open database "NCAccounts" requested by the login. The login failed.
OLE DB provider "SQLNCLI" for linked server "MyLinkedServer" returned message "Invalid connection string attribute".
---------------------------------------------------------------

At this point I noted that DBASE-1 was acting as the Mirror and DBASE-2 was acting as the Principal in the Mirror setup.  So I recreated the Linked Server by interchanging the servers as:
---------------------------------------------------------------
@provstr=N'Server=DBASE-2;Partner=DBASE-1',
---------------------------------------------------------------
and it worked! (Please note that DBASE-1 and DBASE-2 have been interchanged here)

QUESTION: Won't Linked Server automatically consider and switch between the Primary and Partner (Mirror) DBs in the wake of a failover?

Thank you in advance for any replies.
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

I presume you are in the situation where the instance hosting DBASE-2 was up, but DBASE-2 itself not available... at least, that would explain the first error ...

the connection string might be changed slightly: "Failover Partner" instead of "Partner"
http://www.connectionstrings.com/sql-server-2005

apart from that: what exact version are you running?
ASKER CERTIFIED SOLUTION
Avatar of ARSSE
ARSSE

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ARSSE
ARSSE

ASKER

Took up on the hint provided in the previous post and came up with the solution for my problem.