terça-feira, 29 de janeiro de 2008

@@servername and SERVERPROPERTY('servername')

This two sql structures are suposed to return the same information, but in some cases they don´t.

There is something about where @@servername ans serverproperty(‘servername’) picks up the information. @@servername picks from sysservers, and (I don´t know why) this can be different from serverproperty, that returns the machinename plus the instance name.

SERVERPROPERTY(‘servername’) reports changes of network machine name, while @@servername don’t´, you shoul change it manually using  sp_dropserver and sp_addserver.

There is some information on books online about that.

1 comentários:

Tolosa disse...

Ok... I think that you are the guy that can help with an issue about this curious thing.

I have a BD instance that is named SRVBD1\INST01,0001
This is working properly, except when I need to create a LOCAL PUBLICATION on this server.

The name of this instance was SRVBD1\INST01 before, and I don't no for what reason, they changed the name of the instance some time ago.

First, I tried to create in the simple mode, right click -> new publication. In the first time it gave me an error (Something that was conflicting between the old name and the new name). I looked in internet for this error, and found this solution.

EXEC sp_dropserver 'SRVBD1\INST01'
GO

EXEC sp_addserver 'SRVBD1\INST01,001', 'local'
GO

Then I restarted the server and it worked properly. So I finally got in the CREATE LOCAL PUBLICATION WIZARD.

I began to set up my necessities but in the last window, when the wizard starts to create the publication, it gave me another error that looks similar to the first one that I solved before.

I looked in the internet again, and I found an article that was talking about this SERVERPROPERTY('servername') that you're talking about. So I run the query into my server and got DIFFERENT VALUES for this property and for the @@servername (this one is correct).

The @@servername variable is with the correct value since I run the commands that I mentioned before, but the SERVERPROPERTY('servername') property is with the first name of the instance and I don't know how to solve this issue.

I really think that the error that I am taking while trying to create my LOCAL PUBLISHER has something related with this property.

I would really appreciate any help.
Thanks in advance!