Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 @@server returning nothing

Author  Topic 

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2006-02-15 : 19:56:05
How to fix it?

Thanks

mk_garg

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2006-02-15 : 20:01:29
i mean @@servername is returning null

mk_garg
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-15 : 20:02:00
@@SERVER is not a global variable. Do you mean @@SSERVERNAME? If so, check out sp_addserver.

Tara Kizer
aka tduggan
Go to Top of Page

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2006-02-15 : 21:01:50
Hi,

Let me clarify again.

I am using SQL Server 7.0.
When i run print @@servername command on local machine.
It does not return anything.

I executed
sp_addserver @server = 'SYDETST1', @local = 'local'
print @@servername

still no output.

I would like to get name of server using print @@servername.

What i have to do for this?

Thanks




mk_garg
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-02-15 : 21:06:46
you need to restart SQL Server for that change to take affect.



-ec
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-15 : 21:09:52
From Books OnLine on @@SERVERNAME
quote:
SQL Server Setup sets the server name to the computer name during installation. Change @@SERVERNAME by using sp_addserver and then restarting SQL Server. This method, however, is not usually required.

With multiple instances of SQL Server installed, @@SERVERNAME returns the following local server name information if the local server name has not been changed since setup.
Instance                           Server information
Default instance 'servername'
Named instance 'servername\instancename'
Virtual server - default instance 'virtualservername'
Virtual server - named instance 'virtualservername\instancename'

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.


select 	@@SERVERNAME 			as [@@SERVERNAME], 
SERVERPROPERTY('ServerName') as [SERVERPROPERTY('ServerName')],
SERVERPROPERTY('MachineName') as [SERVERPROPERTY('MachineName')],
SERVERPROPERTY('InstanceName') as [SERVERPROPERTY('InstanceName')],
host_name() as [host_name()]


I got @@SERVERNAME returning NULL on some of my servers also. But SERVERPROPERTY consistantly return the name

----------------------------------
'KH'

everything that has a beginning has an end
Go to Top of Page

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2006-02-15 : 22:19:23
Thanks

got it working!

mk_garg
Go to Top of Page
   

- Advertisement -