Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 HOST_ID() and HOST_NAME() work strange?

Author  Topic 

allmax
Starting Member

3 Posts

Posted - 2004-05-09 : 00:29:41
I am trying to use HOST_ID() sys function. Actually I need a way to uniquely identify a connection and the HOST_ID() seems exactly what I need because it seems to return different values for each connection! However the docs say that HOST_ID() must return the workstation identification number (which I guess must be same for each session/connection at the same workstation)?

Also the HOST_NAME() sys function returns empty string (not that I need it now, but...)?

Somebody knows something?

Thanks
allmax

SQLServerDBA_Dan
Aged Yak Warrior

752 Posts

Posted - 2004-05-09 : 20:33:37
These two functions are obtainable in the sysprocesses table.

These queries return the same results:
select hostname, hostprocess from master..sysprocesses where spid = @@spid
select host_name(), host_id()

The hostname returns the name of the machine that the connection was established from but it is modifiable by the application's connection string, so be aware that it may not read what you think it should.

The hostprocess is the PID (process id) on the machine that the connection was established from. If you're using terminal server then you may be out of luck on the PID info.

Hostname is not available on system processes.

Hope that helps.




Daniel
SQL Server DBA
Go to Top of Page

allmax
Starting Member

3 Posts

Posted - 2004-05-10 : 02:17:54
Tx a lot Daniel, this helped me!
Go to Top of Page

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-05-12 : 21:51:26
If you have Windows 98 clients they will have blank hostname in sysprocesses.
Go to Top of Page
   

- Advertisement -