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 2005 Forums
 Transact-SQL (2005)
 Retrive Client System name of IP

Author  Topic 

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-29 : 06:59:52
How retrieve client System name and IP address to connect sql server database?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-29 : 07:01:15
ipconfig from command prompt to get ip address

Client System name by right clicking my computer and from properties -> machine name

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-29 : 07:22:50
I have write a trigger of one table to insert record of one table to another table at this time i have insert client host name or ip address

i have insert a first table record using one application.

i have use host_name or SELECT client_net_address
FROM sys.dm_exec_connections
WHERE Session_id = @@SPID
but this return a server ip address or server name. i want to client ip or client system name to connected of my application within a trigger.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-29 : 07:46:25
oh ok for that use HOST_NAME() function and your query above for ip address

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-29 : 23:06:38
i can use this but it is return server name , i want to client machine name.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2013-05-29 : 23:43:04
quote:
Originally posted by amirs

i can use this but it is return server name , i want to client machine name.



No. HOST_NAME() returns client machine name.
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-29 : 23:57:09
No its returns Machine Name, i have call in trigger
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-29 : 23:59:16
No its returns SQL Server Machine Name, i have call in trigger
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-30 : 01:31:11
quote:
Originally posted by amirs

No its returns SQL Server Machine Name, i have call in trigger


what do you mean by SQL Server Machine name?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-30 : 02:07:46
its server name to installed sql server
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-30 : 02:11:01
quote:
Originally posted by amirs

its server name to installed sql server


where exactly are you executing this code from? Are you executing this from the same machine itself?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-30 : 02:20:48
No i have one front end application within this application i have insert a record of one table. i have write the trigger of this table.
the trigger is execute when insert record of table. i have write this code within trigger, so i want know which machine name is use this application to insert a record.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-30 : 02:34:03
hmm..in that case it might be probabaly worth capturing this in front end table used by application using HOST_NAME and in trigger just retrieve it from the table.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -