Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Check for linked server - supress messages (TSQL/PHP)

$
0
0
Hello community!I found a script to check if a linked server is online. [code="sql"]ALTER PROCEDURE [dbo].[uspLinkedServerOnline] @isOnline bit OUTPUTASBEGIN SET NOCOUNT ON; DECLARE @serverName SYSNAME = N'NB011\SQLDEV2014'; BEGIN TRY EXEC master.sys.sp_executesql N'EXEC sp_testlinkedserver @servername;', N'@serverName SYSNAME', @serverName SELECT @isOnline = 1; END TRY BEGIN CATCH SELECT @isOnline = 0; END CATCHEND[/code]If I stop the linked server, the stored procedure returns "0" in the results window. In the "messages" window i get the following warnings << OLE DB provider "SQLNCLI11" for linked server "NB011\SQLDEV2014" returned message "Login timeout expired". >><< OLE DB provider "SQLNCLI11" for linked server "NB011\SQLDEV2014" 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." >>The stored procedure is executed successfully when executed in SSMS. I checked the profiler and see that the SP is executed and completed when called from the PHP script. However, the calling function in PHP gets the messages as the result and the part of the script fails then.Is there an option to suppress the messages within a specific SP?Or is this a specific function in PHP?Thank you for your help

Viewing all articles
Browse latest Browse all 3145

Trending Articles