Solved

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

Posted on 2010-08-23
5
264 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now