Solved

SERVERPROPERTY('SERVERNAME') & @@SERVERNAME

Posted on 2010-08-23
14
1,020 Views
Last Modified: 2012-05-10
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
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
  • 7
  • 3
  • 2
  • +1
14 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 33504395
you're getting 2 different values?  what are you getting?
0
 
LVL 30

Accepted Solution

by:
Rich Weissler earned 400 total points
ID: 33504423
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
 
LVL 6

Author Comment

by:anushahanna
ID: 33504431
select SERVERPROPERTY('SERVERNAME') is JMRW185422
select @@SERVERNAME is CO6849B546
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 6

Author Comment

by:anushahanna
ID: 33504440
select SERVERPROPERTY('SERVERNAME')  corresponds correctly to the machine name and the default instance also.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 33504451
renamed the server recently?
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33504635
renamed the server recently?

no.. just seen it lately.. so no workable issues with it...
0
 
LVL 11

Expert Comment

by:mattibutt
ID: 33506179
Have you changed computer name after the install
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33507214
I had not; at least after SQL install, computer name was not changed.
0
 
LVL 11

Assisted Solution

by:mattibutt
mattibutt earned 100 total points
ID: 33537496
Try to reinstall sql server
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33538527
just to change @@SERVERNAME?
0
 
LVL 30

Expert Comment

by:Rich Weissler
ID: 33542135
*confused*  Sorry, didn't realize this was still under discussion:

What happens if you execute:
sp_addserver 'local'
and then compare?
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33544612
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
 
LVL 30

Assisted Solution

by:Rich Weissler
Rich Weissler earned 400 total points
ID: 33544657
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
 
LVL 6

Author Comment

by:anushahanna
ID: 33545007
I ran sp_addserver 'local'

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

should i restart the services?
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

695 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