Wednesday, 7 July 2010

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

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')

Result:
Computer1, Computer2

Server Machine (Computer2):

Select Host_Name(), ServerProperty('MachineName')

Result:
Computer2, Computer2

No comments:

Post a Comment