Solved

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

Posted on 2010-08-23
5
274 Views
Last Modified: 2012-05-10
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
Comment
Question by:anushahanna
  • 2
  • 2
5 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 334 total points
ID: 33503991
Nope.  The first will return the instance name while the 2nd returns the physical machine name.
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33504008
so first one is from installation and second one is live?
0
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 334 total points
ID: 33504022
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
 
LVL 12

Assisted Solution

by:mcv22
mcv22 earned 166 total points
ID: 33504034
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
 
LVL 6

Author Comment

by:anushahanna
ID: 33504152
Thanks very much for the clear diff between the two.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS SQL with ODBC 5 36
stored procedures times out after 2 hours in sql server 2014 16 38
Sql server function help 15 31
Sql Server group by 10 29
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question