May 17, 2005 at 3:56 pm
We have an application that relies on the value of @@Servername, but on all three instances of developer edition SQL Server installed on our XP Pro test machine, this returns NULL. The default instance is 7.0, the two named instances are 2000 and 2005 (April).
Tried running sp_addserver, rebooting the instances (and even XP), but to no avail. Is this a known "feature", or am I missing something? Is there a system table I can update directly to fix this?
Thanks!
May 18, 2005 at 12:39 am
Hmmm, I'm running Developer (2000) as a named instance on an XP Pro machine (SP 1) and @@Servername returns the name of the instance.
Have you tried through query analyser, or just through your app?
Is the server perhaps case-sensitive (don't know if that would make a difference)
What's the patch level of the 7.0 and 2000 databases?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 18, 2005 at 12:54 am
What does SELECT SERVERPROPERTY('Servername') return?
May 18, 2005 at 2:17 am
The only time I have seen this is when certain registry keys have been deleted. ie the \CurrentVersion and \Parameters ones
from
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\
Steven
May 18, 2005 at 2:36 am
If I remember correctly @@servername relies on master..sysservers table. Can you examine its contents? There should be at least one row holding info about local server (isremote column=0)
May 18, 2005 at 3:25 am
I was thinking of the version info going, with the reg keys above.
To get rid of the null I usually use the following, code
exec sp_dropserver '<oldname>'
exec sp_addserver '<newname>', 'local'
Steven
May 18, 2005 at 3:58 am
Check to see that SELECT SERVERPROPERTY('Servername') and @@Servername return the same instance name. If they don't then drop the server and re add it as above.
May 18, 2005 at 9:13 am
@@servername will return null if you run sp_addserver 'servername' without the additional 'local' parameter. Conveniently enought Books online tells you to do this wrong. Always make sure that you add the 'local' parameter to sp_addserver and everything should be gravy.
May 19, 2005 at 12:11 pm
Thanks for all the fish!
The trick was dropping the server before trying to add it as "local". I had been trying to add it as local without first dropping it, using the "duplicate_OK" flag. Once I successfully dropped the server name (after taking care of some interfering replication), I was able to add it locally and then restart the instance.
Thanks again for all the input!
May 31, 2005 at 9:16 am
Also, you will have to stop/restart the SQL Server service.
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply