Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

SERVERPROPERTY('SERVERNAME') & SERVERPROPERTY('MACHINENAME')

Are the above 2 always going to the same, guaranteed?

Are they absorbed at installation of SQL? or do they read from OS, live?

Thanks
0
anushahanna
Asked:
anushahanna
  • 2
  • 2
3 Solutions
 
chapmandewCommented:
Nope.  The first will return the instance name while the 2nd returns the physical machine name.
0
 
anushahannaAuthor Commented:
so first one is from installation and second one is live?
0
 
chapmandewCommented:
1st one is the instance.  So, say you have a machine named machine1.  On machine 1 you have 2 instances, the default and a named one (named Instance2).  If you run these on instance2, you'll get:

Machine1\Instance2
Machine1

however, if you run it on the default instance, they'll both return Machine1.  Make sense?
0
 
mcv22Commented:
SERVERPROPERTY('MACHINENAME') is pulled from the OS. If you change the computer name, you will be prompted for a restart after which you would be able to see the new machine name if you run the query again.

SERVERPROPERTY('SERVERNAME') is initially set during SQL setup. It can however be changed at a later time by using sp_dropserver and sp_addserver 'newname', 'local'
0
 
anushahannaAuthor Commented:
Thanks very much for the clear diff between the two.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now