Connecting Tech Pros Worldwide Help | Site Map

find server name using query

Newbie
 
Join Date: Jun 2007
Posts: 1
#1: Jun 6 '07
how we find the server name using sqlserver2005-Query analyser
Member
 
Join Date: May 2007
Location: Chennai
Posts: 99
#2: Jun 6 '07

re: find server name using query


Use the following query
select @@servername
Member
 
Join Date: Jun 2007
Posts: 44
#3: Jun 8 '07

re: find server name using query


Quote:

Originally Posted by Vidhura

Use the following query
select @@servername

@@ServerName returns the servername of the sql server and

Expand|Select|Wrap|Line Numbers
  1.  select serverproperty('MachineName') 
  2.  
gives the box name in which sql server is running.
Newbie
 
Join Date: Jun 2007
Posts: 1
#4: Jun 18 '07

re: find server name using query


to find machine name by sql qury : select host_name();
to find machine name and ip addrss by c# :
string hostName = Dns.GetHostName();
listBox1.Items.Add ("Host Name = " + hostName);
//v can also use this
//IPHostEntry local =Dns.GetHostByName(hostName);
IPHostEntry local = Dns.GetHostEntry(hostName);
foreach (IPAddress ipaddress in local.AddressList)
{
listBox1.Items.Add ("IPAddress = " + ipaddress.ToString());
}
Reply