According to BOL extended stored procedure sys.sp_testlinkedserver returns 0 on successfully connecting to linked server and 1 when it fails. But I tried this
Created a linked server to default instance of 2000 called TEST
and used following script to test the extended stored procedure and instead of printing my PRINT statement it generated error
-- CHECK LINKED SERVER CONNECTION
DECLARE @a int
SET @ServerName = 'TEST'
IF EXISTS(SELECT 1 FROM master.dbo.sysservers WHERE srvname LIKE @ServerName)
BEGIN
EXEC @a = sys.sp_testlinkedserver @servername = @ServerName
IF @a = 0
print 'LINKED SERVER ''' + ISNULL(@ServerName,'') + ''' IS CONNECTED.'
ELSE
print 'LINKED SERVER ''' + ISNULL(@ServerName,'') + ''' IS NOT CONNECTED!'
END
ELSE
BEGIN
PRINT 'LINKED SERVER '''+ ISNULL(@ServerName,'') + ''' DOES NOT EXIST!'
END
Here is the error message
----------------------------------------------------------------------------------------------------------
OLE DB provider "SQLNCLI" for linked server "TEST" returned message "Invalid authorization specification".
Msg 7399, Level 16, State 1, Procedure sp_testlinkedserver, Line 1
The OLE DB provider "SQLNCLI" for linked server "TEST" reported an error. Authentication failed.
Msg 7303, Level 16, State 1, Procedure sp_testlinkedserver, Line 1
Cannot initialize the data source object of OLE DB provider "SQLNCLI" for linked server "TEST".
----------------------------------------------------------------------------------------------------------
Can anyone guess why

sys.sp_testlinkedserver
Tryin2Bgood
chub xbox
Val P
aztec2_step
You're running this from an external source...not from within SQL Server Analyzer or Management Studio...
It's trying to authenticate you through a portal.
My guess, you're using ASP or PHP and you don't have authentication privileges through SQL Server authentication.
Add ASP.net or PHP with a password to your connection string.
Adamus
johnny_no1_boy
GiampaoloSanRemo
I added this thread and i got a message saying error occured in forum so I tried again and 3 seperate threads got created.
Tried to delete ...aint workin!!!!
Moderator plz delete 2 of those extra threads please!
Ariel Valentin
if you execute
sys.sp_testlinkedserver @servername
= N'NON_EXISTANT_SRVR'on a server that does not exist this call hangs forever.
I'm not quite sure if it's forever but 6 minutes plus is way to long.
Is there anything that can be done to make this command usable