Select Machine Name (Client or Server) and Instance Names (SQL Server)

Send Us a Sign! (Contact Us!)
Word PDF XPS Text

To get the instance name:

SELECT @@ServerName

To get the machine name of the server:

SELECT SERVERPROPERTY(“MachineName”)

To get the machine name of the computer running the query:

SELECT host_name()

One tip: cast the serverproperty as a varchar if you want to use it in a [gs string] or you will get errors in your [gs stored procedure]s/[gs query]/ies.

SOURCE

LINK

LANGUAGE
ENGLISH

2 thoughts on “Select Machine Name (Client or Server) and Instance Names (SQL Server)”

Comments are closed.