instance_id

Description

Returns the id of the named instance, or the instance from which it is issued if you do not provide a value for name.

Syntax

instance_id([name])

Parameters

name – is the name of the instance whose id you are researching.

Example

Returns the id of the local instance:

select instance_id()

Returns the id of the instance named “myserver1”:

select instance_id(myserver1)

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute instance_id.