Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

sqlsrv_server_info

SQL Server 2008 R2

Returns information about the server. A connection must be established before calling this function.


sqlsrv_server_info( resource $conn)

$conn: The connection resource by which the client and server are connected.

An associative array with the following keys:

Key

Description

CurrentDatabase

The database currently being targeted.

SQLServerVersion

The version of SQL Server.

SQLServerName

The name of the server.

The following example writes server information to the console when the example is run from the command line.

<?php
/* Connect to the local server using Windows Authentication. */
$serverName = "(local)";
$conn = sqlsrv_connect( $serverName);
if( $conn === false )
{
     echo "Could not connect.\n";
     die( print_r( sqlsrv_errors(), true));
}

$server_info = sqlsrv_server_info( $conn);
if( $server_info )
{
      foreach( $server_info as $key => $value)
      {
             echo $key.": ".$value."\n";
      }
}
else
{
      echo "Error in retrieving server info.\n";
      die( print_r( sqlsrv_errors(), true));
}

/* Free connection resources. */
sqlsrv_close( $conn);
?>
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.