To get the SQL Server instance name with T-SQL use one of the following two statements:
- select @@SERVERNAME
- select SERVERPROPERTY('SERVERNAME')
Important: The
SERVERNAME property of the
SERVERPROPERTY function uses the computer's current network name. So, if the computer (on which the SQL Server instance is installed) had its network name changed after the SQL Server instance was installed, the
SERVERPROPERTY function will pick up the new name -
@@SERVERNAME will not!
@@SERVERNAME will use the network name of the computer at the time when the instance of SQL Server was installed.
Click
here to see more properties of the
SERVERPROPERTY function.
No comments:
Post a Comment