How To Ideas | How To Articles | How To Tutorials


0

How To Find the SQL Server Instance Name and Machine Name using Query in SQL Server


You can easily, with just a single query of 4-5 words, fetch your Machine name and SQL Server Instance name. Machine name is the one which can be find by right clicking your Computer and then selecting Properties from the right click context menu and SQL Server Instance name is the one to which you are currently logged in, in your SQL Server. Actually you can have multiple Instances of SQL Server and every instance can have a number of different Logins. These can be setup during the installation of the product only and if later you want to add instances to SQL Server, you have to install the instance separately using the CD. The instance name can be found on the login screen of SQL Server.

Computer Name or Machine Name SQL Server Instance Name

Instructions:

  1. Using @@SERVERNAME function
    • With this you can only fetch the name of SQL Server instance to which you are currently logged in.

      SELECT @@SERVERNAME AS "Server Name"

      Fetch SQL Server Instance Name using @@SERVERNAME Function

  2. Using  SERVERPROPERTY function
    • With this you can fetch both Machine name as well as SQL Server Instance name. Here is an example to fetch the SQL Server Instance name.

      SELECT SERVERPROPERTY('SERVERNAME') AS "Server Name"

      Fetch SQL Server Instance Name using SERVERPROPERTY Function

    • Here is an example to fetch the Machine name.

      SELECT SERVERPROPERTY('MACHINENAME') AS "Machine Name"

      Fetch Machine/Computer Name using SERVERPROPERTY Function

Filed in: SQL Server Tags: , , , , , ,

Leave a Reply

Submit Comment



© 2878 How To Ideas. All rights reserved.
Proudly designed by Theme Junkie.