Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-08-23
5
Medium Priority
?
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 1336 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 1336 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 664 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

705 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