A place to learn from Little Techie...
Little Techie who is Microsoft Most Valuable Professional (MVP), Most Valuable Contributor (MVC), Most Valuable Member (MVM), Member of the Year..........
Pages
▼
Friday, January 15, 2010
Getting the Server Name in SQL Server using @@SERVERNAME
In this post i would like to give you a simple tip on how to get the Server Name of the SQL server.
In order to get the SQL Server - Server name you need to use Global Variable as shown below.
Just wanted to add something to your post. If servername is changed then @@servername still points to the oldname. Updated name can be found by Serverproperty('Servername').
Updated servername will reflect on sql server after one does sp_dropserver and then continue with sp_addserver 'newname','local' and then perform a service restart.
You may be aware of these. Just wanted to add to ur post. :)
Hi vijay,
ReplyDeleteJust wanted to add something to your post. If servername is changed then @@servername still points to the oldname. Updated name can be found by Serverproperty('Servername').
Updated servername will reflect on sql server after one does sp_dropserver and then continue with sp_addserver 'newname','local' and then perform a service restart.
You may be aware of these. Just wanted to add to ur post. :)
Regards,
Raj