Partilhar via


SERVERPROPERTY (Transact-SQL)

Returns property information about the server instance.

Important

This feature has changed from earlier versions of Microsoft SQL Server. For more information, see Behavior Changes to Database Engine Features in SQL Server 2005.

Topic link iconTransact-SQL Syntax Conventions

Syntax

SERVERPROPERTY ( propertyname )

Arguments

  • propertyname
    Is an expression that contains the property information to be returned for the server. propertyname can be one of these values.

    Property name

Return Types

sql_variant

Remarks

The ServerName property of the SERVERPROPERTY function and @@SERVERNAME return similar information. The ServerName property provides the Windows server and instance name that together make up the unique server instance. @@SERVERNAME provides the currently configured local server name.

The ServerName property and @@SERVERNAME return the same information if the default server name at the time of installation has not been changed. The local server name can be configured by executing the following:

EXEC sp_dropserver 'current_server_name';
GO
EXEC sp_addserver 'new_server_name', 'local';
GO

If the local server name has been changed from the default server name at installation time, @@SERVERNAME returns the new name.

Examples

The following example uses the SERVERPROPERTY function in a SELECT statement to return information about the current server. This scenario is useful when there are multiple instances of SQL Server installed on a Windows server, and the client must open another connection to the same instance used by the current connection.

SELECT CONVERT(char(20), SERVERPROPERTY('servername'));
GO

See Also

Reference

@@SERVERNAME (Transact-SQL)

Other Resources

Editions and Components of SQL Server 2005

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

14 April 2006

New content:
  • Added the EditionID property.
  • Added Express Edition with Advanced Services values to Edition, EngineID, and EngineEdition.
Changed content:
  • Indicated Personal and Desktop editions are limited to earlier versions of SQL Server.
  • Inserted EngineEdition mappings for Workgroup Edition and Windows Embedded SQL Edition.