System Functions Used in Multi-Instance Installations

Two system functions return information related to instances:

  • SERVERPROPERTY—This function takes one parameter and returns information about the server where the instance is installed. If the parameter is machinename, this function returns the name of the server. If the parameter used is servername, it returns the name of the server, along with the name of the instance. If instancename is used as the parameter, the function returns the name of the current instance, and if it's the default instance, it returns NULL. Listing A.3 shows how to use this function with the parameters described.

Code Listing A.3. Using the SERVERPROPERTY Function
					 USE Master SELECT SERVERPROPERTY('machinename') SELECT ...

Get Microsoft® SQL Server™ 2000 Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.