@@SERVERNAME
reads configuration (@@ function)
What changes
- Input
- server or session configuration state
- Output or change
- value
- Return type
- nvarchar
Syntax at a glance
@@SERVERNAME
Work example
Read the configured SQL Server name in a diagnostic result.
Read in the same session and compare before and after a controlled session setting change.
Check your work The configured value can differ from a connection endpoint or DNS name.
Open Microsoft Learn for full syntax, permissions, and details for your version.