In an effort to mimic a production environment I've added a linked server in MSSQL that points to itself. This allows me to test SQL scripts which are run in production on my own machine.
EXEC master.dbo.sp_addlinkedserver
@server = N'LinkedServer',
@srvproduct=N'',
@provider=N'SQLNCLI',
@provstr=N'DRIVER={SQL Server};Server=(localdb)\MSSQLLocalDb; Initial Catalog=MyOtherDatabase;Integrated Security=true'
This works great when I just open management studio to do queries or run .NET code that does queries while using integrated security.
However when I open management studio using run as administrator, or run .NET code with run as administrator the linked server connection fails.
SQL Server Network Interfaces: [x89C50118].
OLE DB provider "SQLNCLI11" for linked server "LinkedServer" returned message "Login timeout expired".
OLE DB provider "SQLNCLI11" for linked server "LinkedServer" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".
OLE DB provider "SQLNCLI11" for linked server "LinkedServer" returned message "Invalid connection string attribute". (Microsoft SQL Server, Error: -1983577832)
How can I get this to work?