• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1118
  • Last Modified:

SERVERPROPERTY('SERVERNAME') & @@SERVERNAME

Even though both these come from the SQL installation, they are different. How could that have happened?

Are they looking at 2 diff source, even though they are derived from the installation?

Thanks
0
anushahanna
Asked:
anushahanna
  • 7
  • 3
  • 2
  • +1
3 Solutions
 
chapmandewCommented:
you're getting 2 different values?  what are you getting?
0
 
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooterCommented:
From the BoL:
"Although the @@SERVERNAME function and the SERVERNAME property of SERVERPROPERTY function may return strings with similar formats, the information can be different. The SERVERNAME property automatically reports changes in the network name of the computer.In contrast, @@SERVERNAME does not report such changes. @@SERVERNAME reports changes made to the local server name using the sp_addserver or sp_dropserver stored procedure."
0
 
anushahannaAuthor Commented:
select SERVERPROPERTY('SERVERNAME') is JMRW185422
select @@SERVERNAME is CO6849B546
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
anushahannaAuthor Commented:
select SERVERPROPERTY('SERVERNAME')  corresponds correctly to the machine name and the default instance also.
0
 
chapmandewCommented:
renamed the server recently?
0
 
anushahannaAuthor Commented:
renamed the server recently?

no.. just seen it lately.. so no workable issues with it...
0
 
mattibuttCommented:
Have you changed computer name after the install
0
 
anushahannaAuthor Commented:
I had not; at least after SQL install, computer name was not changed.
0
 
mattibuttCommented:
Try to reinstall sql server
0
 
anushahannaAuthor Commented:
just to change @@SERVERNAME?
0
 
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooterCommented:
*confused*  Sorry, didn't realize this was still under discussion:

What happens if you execute:
sp_addserver 'local'
and then compare?
0
 
anushahannaAuthor Commented:
Thanks Razmus,
just to confirm

with the current state being:
select SERVERPROPERTY('SERVERNAME') is JMRW185422
select @@SERVERNAME is CO6849B546

you recommend the foll:
sp_addserver 'local'
to see if the 2 results will sync up?
0
 
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooterCommented:
Yes.
 That's based upon: http://msdn.microsoft.com/en-us/library/ms174411.aspx
"Specifying @local as LOCAL defines @server as the name of the local server and causes the @@SERVERNAME function to return the value of server. "
0
 
anushahannaAuthor Commented:
I ran sp_addserver 'local'

still
select SERVERPROPERTY('SERVERNAME') is JMRW185422
select @@SERVERNAME is CO6849B546

should i restart the services?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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