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.
Author |
Topic |
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2006-02-15 : 19:56:05
|
How to fix it?Thanksmk_garg |
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2006-02-15 : 20:01:29
|
i mean @@servername is returning nullmk_garg |
 |
|
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 Kizeraka tduggan |
 |
|
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 executedsp_addserver @server = 'SYDETST1', @local = 'local' print @@servernamestill no output.I would like to get name of server using print @@servername.What i have to do for this?Thanksmk_garg |
 |
|
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 |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-15 : 21:09:52
|
From Books OnLine on @@SERVERNAMEquote: 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 informationDefault 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 |
 |
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2006-02-15 : 22:19:23
|
Thanksgot it working!mk_garg |
 |
|
|
|
|
|
|