Hi we have always on server 2016 R2 configured and read only routing also configured . Basically "user1" connect from client server and display as secondary server. That ensured the read only routing is working
sqlcmd.exe -S LSNRname -d databasename -E -K ReadOnly
1> Go
2> Select @@servername
3> Go
--------------------------
Question is on same client server(other 2016 R2 SQl server) I need to create a linked server to always on. and i created as follows.
EXEC sp_addlinkedserver
@server = N'Linkservername,
@srvproduct=N'SqlServer',
@provider=N'SQLNCLI11',
@datasrc=N'Listenenrname ',
@provstr=N'ApplicationIntent=ReadOnly',
@catalog=N'DBname';
.Linked server created.
then I run following command to see which server is accessing from clinet server
select * from OPENQUERY ( [Linkservername] ,'select @@servername' )
Its returned the correct servername.
Q1. I am not sure what user is use to connect which assess DB from the link. When select "Be made using the login's current security context"
Q2 . Secondly when I try to add user on , then I am getting error. But please note I connect using SSMS same user specifying listenername + ApplicationIntent=ReadOnly and connected correctly. Not sure why. Any one has any idea would be great .