Data Haunting

Easy Solutions Destination

By

How to find Host name, Server name, User name and DataBase name in Sql server

Frequently in interview we face the question that how to get Host name, Machine name, Server name, User name and DataBase name of Sql Server which are connected in Networks. In this article we will see that how to find Host name Machine name, Server name, User name and DataBase name using Sql select query in Sql Server management studio which is quite easy.

Get Host name in Sql Server

Host name means in which Sql server database is connected. So let’s see how to get Host name of Sql Server which are connected in Networks.

In above query we have used HOST_NAME of sql server which gives host name of sql server.

Get Machine Name in Sql Server

Machine name in which Sql server is installed or hosted. So let’s see how to get machine name of Sql Server which are connected in Networks.

In above query we have used serverproperty of sql server with Machinename which turns into desired results.

Get Server name in Sql Server

Server name we can get with or with out serverproperty . So let’s see both query to get Server name of Sql Server which are connected in Networks.

Get User name in Sql Server

We can get User name with following two query in Sql server.

Get DataBase name in Sql Server

In Sql server current Database name can be fetched with following query

What is your opinion ?

Here we have seen different different Sql Server’s query to find Host name, Machine name, Server name, User name and DataBase name in networks. If you have any query and question, you can comment or you can mail me.

Leave a Reply