What is the difference between Host_Name() and ServerProperty('MachineName') Functions ?

 Posted by PandianS on 5/24/2010 | Category: Sql Server Interview questions | Views: 7414

The Host_Name() and ServerProperty('MachineName') Function will return the System Name(Machine Name).

But the difference is ...

Host_Name() will return the Client Machine name.

ServerProperty('MachineName') will return Server Machine name.

ie: CLIENT SQL Server tools only installed on "Computer1" (SQL Server Management Studio) - Connectivity tools only

SERVER SQL Server tools installed on "Computer2" (Databases, SQL Server Services, SQL Server Management Studio, Profiler,...Etc.,)

Now You are the "Client machine (Computer1)", You want to access the Database from the "Server Machine (Computer2)".

Client Machine (Computer1):

Select Host_Name(), ServerProperty('MachineName')

Computer1, Computer2

Server Machine (Computer2):

Select Host_Name(), ServerProperty('MachineName')

Computer2, Computer2

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Samanthajyesta on: 5/25/2010
here the methods Host_Name() and
serverProperty('MachineName') do the same. but the difference
is that

Host_Name returns the name of the client machine.
where as the serverProperty('MachineName') returns the name of the server machine.

Login to post response