find server name using query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sundaram Muthusamy
    New Member
    • Jun 2007
    • 1

    #1

    find server name using query

    how we find the server name using sqlserver2005-Query analyser
  • Vidhura
    New Member
    • May 2007
    • 99

    #2
    Use the following query
    select @@servername

    Comment

    • siva538
      New Member
      • Jun 2007
      • 44

      #3
      Originally posted by Vidhura
      Use the following query
      select @@servername
      @@ServerName returns the servername of the sql server and

      Code:
       select serverproperty('MachineName')
      gives the box name in which sql server is running.

      Comment

      • vignessh
        New Member
        • Jun 2007
        • 1

        #4
        Check it out ?!

        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.GetHostByN ame(hostName);
        IPHostEntry local = Dns.GetHostEntr y(hostName);
        foreach (IPAddress ipaddress in local.AddressLi st)
        {
        listBox1.Items. Add ("IPAddress = " + ipaddress.ToStr ing());
        }

        Comment

        Working...