Solved

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

Posted on 2010-08-23
5
253 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
Comment Utility
Nope.  The first will return the instance name while the 2nd returns the physical machine name.
0
 
LVL 6

Author Comment

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

Assisted Solution

by:chapmandew
chapmandew earned 334 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks very much for the clear diff between the two.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

744 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

11 Experts available now in Live!

Get 1:1 Help Now