@@Servername

  • Hi,

    I have named instance in sql server 2000 version. while executing the @@servername command its giving the server name as value "Null".

    Can anybody tell me the reason why its giving result like that or is there any issue at server ?

    Thanks in Advance.

  • Sudhakara ,

    That's strange..! The serverproperty gives entire details of the SQL server.

    Again cross check the server name from services section.

    Refer the link:

    http://msdn.microsoft.com/en-us/library/aa933172(SQL.80).aspx

    Thanks.

  • has this server been renamed at some point?

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Check out sp_AddServer in BOL.

    You'll probably need to run it as:

    execute sp_AddServer 'MyServerName', 'LOCAL'

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Sourav-657741 (4/25/2010)


    Sudhakara ,

    That's strange..! The serverproperty gives entire details of the SQL server.

    Again cross check the server name from services section.

    Refer the link:

    http://msdn.microsoft.com/en-us/library/aa933172(SQL.80).aspx

    Thanks for all,

    can you tell what kind of problem may occur if its continues ?.

  • Can you get the information running this query?

    SELECT CONVERT(sysname, SERVERPROPERTY('servername'));

    If not, you may have an issue with the server, it's configuration, your connections... not sure.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • I've seen this before- I'd bet your server isn't registered as "local"

    Try selecting from master.Sys.servers- (select * from master.sys.servers)

    you're local servername should be server_id= 0

    if it's not- I think you need to drop and readd

    exec sp_dropserver 'myserver'

    exec sp_addserver 'myserver',local

    Good luck

    Ben Pflanzer

  • Grant Fritchey (4/26/2010)


    Can you get the information running this query?

    SELECT CONVERT(sysname, SERVERPROPERTY('servername'));

    If not, you may have an issue with the server, it's configuration, your connections... not sure.

    Yes. That select statement displaying the name of the server.But here name of the instance and name of the server is different.

    Thanks.

  • bpflanzer (4/26/2010)


    I've seen this before- I'd bet your server isn't registered as "local"

    Try selecting from master.Sys.servers- (select * from master.sys.servers)

    you're local servername should be server_id= 0

    if it's not- I think you need to drop and readd

    exec sp_dropserver 'myserver'

    exec sp_addserver 'myserver',local

    Good luck

    Ben Pflanzer

    Its a named instance in the server. Server id column has value as 1.

  • sudhakara (4/28/2010)


    Grant Fritchey (4/26/2010)


    Can you get the information running this query?

    SELECT CONVERT(sysname, SERVERPROPERTY('servername'));

    If not, you may have an issue with the server, it's configuration, your connections... not sure.

    Yes. That select statement displaying the name of the server.But here name of the instance and name of the server is different.

    Thanks.

    OK. That's good. Then you can also call the SERVERPROPERTY function with 'InstanceName' to get the instance. If that's accurate, you might be OK.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • since the serverid <> 0 it's considered a "remote" server.

    for @@servername to return properly- you'll need to drop and add as stated earlier:

    If you look up sys.servers in BOL- you'll see this:

    Contains a row per linked or remote server registered, and a row for the local server that has server_id = 0.

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply