October 13, 2005 at 2:46 pm
Strange thing happen....
I have been using an sql code that include @@servername to retrieve name of local server.
I tried this on several SQL server and it works, but after others test I have found out an error during batch process......the error occur because in an sql server the system variable @@servername was empty.
I run the statement print @@servername and the output was empty ....
anyone knows why in some sqlservers @@servername is an empty string ??????
thank a lot
October 13, 2005 at 4:58 pm
possible that master db is corrupted.
if you have a backup of master db , restore it.
October 13, 2005 at 11:51 pm
try using:
select serverproperty('servername')
if this is different to @@servername you need to use sp_addserver to make the output the same.
regards,
Mark Baekdal
+44 (0)141 416 1490
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change management for SQL Server
October 14, 2005 at 7:21 am
After using sp_addserver, you'll have to stop, then restart, SQL Server.
EXEC sp_dropserver 'yourServerName'
EXEC sp_addserver 'yourServerName', 'local'
Stop SQL Server.
Restart SQL Server.
Also, try either or both of these:
EXEC sp_helpserver
and
SELECT srvid
, srvname
, datasource
, srvnetname
FROM master..sysservers
October 14, 2005 at 11:37 am
I would suggest to replace
EXEC sp_dropserver 'yourServerName'
with
EXEC sp_dropserver 'yourServerName,'droplogins'
October 14, 2005 at 12:14 pm
anyone knows why in some sqlservers @@servername is an empty string ??????
This happens when the server is renamed
Read previous post for the solution!
* Noel
October 15, 2005 at 12:18 am
October 15, 2005 at 12:18 am
October 17, 2005 at 11:47 am
After executing sp_adderver ...,local you need toi stop/restart SQL Server.
Just a little 'undocumented feature' that's been around since v4.21 ...
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
October 17, 2005 at 1:57 pm
That is not correct! I have a named instance in my development computer an it gives me : COMPUTERNAME\INSTANCENAME
* Noel
October 18, 2005 at 2:55 pm
Thank to everybody,
added local server and stop/restart server .......OK
October 18, 2005 at 11:55 pm
October 19, 2005 at 2:24 pm
Thank to everybody.......
December 17, 2008 at 8:32 am
Thanks for the suggestion about using EXEC sp_dropserver 'yourServerName,'droplogins'.
We were just trying to use EXEC sp_dropserver 'yourServerName without the droplogins directive and received errors about a linked server (another developer was using the system with permission).
Dropping the server, re-adding it (sp_addserver...), stopping and re-starting the service corrected the issue.
Now we also get the correct server_id = 0 for the SQL instance in sys.servers (or srvid = 0 in master.dbo.sysservers).
Argue for your limitations, and sure enough they're yours (Richard Bach, Illusions)
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply