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
 General SQL Server Forums
 New to SQL Server Programming
 Remote Ipaddress

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 03:25:11
Can i know the syntax to get the remote ip address which has to be stored in a table.


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-11 : 03:25:56
Remote IP address of what?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 03:27:30
remote ipaddress of different client who access the server
quote:
Originally posted by Peso

Remote IP address of what?



E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-11 : 03:31:07
You can get the machine name with

select host_name()



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 03:35:07
hi peso txs for ur immediate reply,
by using host_name().iam not able to store it in temp/normal table.but while exectuing through stord procedure it gets inserts,incase by calling the stored procedure through front end.some
classical execution error is thrown:

quote:
Originally posted by Peso

You can get the machine name with

select host_name()



E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-11 : 03:37:56
quote:
Originally posted by sent_sara

hi peso txs for ur immediate reply,
by using host_name().iam not able to store it in temp/normal table.but while exectuing through stord procedure it gets inserts,incase by calling the stored procedure through front end.some
classical execution error is thrown:

quote:
Originally posted by Peso

You can get the machine name with

select host_name()



E 12°55'05.25"
N 56°04'39.16"





why cant you store it in table? can i see your insert script?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-11 : 03:41:26
He proabably builds a dynamic string in frontend...



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 03:45:40
CREATE procedure test_sp(@report_name varchar(100))
as
begin
DECLARE @HostName varchar(200)

select @HostName = HOST_NAME()

begin try
begin transaction
insert into user_access_report(report_name,userid,access_date)
select @report_name,@HostName,getdate()

commit transaction
end try

begin catch
rollback transaction
insert into user_access_report(report_name,userid)
select cast(error_number() as varchar), error_message()
end catch


end




quote:
Originally posted by visakh16

quote:
Originally posted by sent_sara

hi peso txs for ur immediate reply,
by using host_name().iam not able to store it in temp/normal table.but while exectuing through stord procedure it gets inserts,incase by calling the stored procedure through front end.some
classical execution error is thrown:

quote:
Originally posted by Peso

You can get the machine name with

select host_name()



E 12°55'05.25"
N 56°04'39.16"





why cant you store it in table? can i see your insert script?

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-11 : 03:50:12
why are you assgning value of host_name to userid? is it a varchar field? also does it have enough length to hold the returned value by hostname?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-11 : 04:03:28
Similar thread
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=108091

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 04:20:27
1) from front end the sp is calling dynamically as peso said,
2) secondly ,to keep track of reports accessed by user,this insertion logic is implemented.

Regards/senthil
quote:
Originally posted by visakh16

why are you assgning value of host_name to userid? is it a varchar field? also does it have enough length to hold the returned value by hostname?

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-11 : 04:21:27
quote:
Originally posted by sent_sara

1) from front end the sp is calling dynamically as peso said,
2) secondly to keep track of user accessign the reports regulary,this insertion logic is implemented.

Regards/senthil
quote:
Originally posted by visakh16

why are you assgning value of host_name to userid? is it a varchar field? also does it have enough length to hold the returned value by hostname?




on agreed. but you didnt answer me. whats the datatype of userid?
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 04:24:19
its varchar(20)

quote:
Originally posted by visakh16

quote:
Originally posted by sent_sara

1) from front end the sp is calling dynamically as peso said,
2) secondly to keep track of user accessign the reports regulary,this insertion logic is implemented.

Regards/senthil
quote:
Originally posted by visakh16

why are you assgning value of host_name to userid? is it a varchar field? also does it have enough length to hold the returned value by hostname?




on agreed. but you didnt answer me. whats the datatype of userid?

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-11 : 04:27:52
quote:
Originally posted by sent_sara

its varchar(20)
And what is the length of the data HOST_NAME() returns?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-11 : 04:28:03
and whats the error obtained when you try to insert it? also it would be good if you can post dynamic script where you try to insert.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-11 : 04:28:59
Change VARCHAR(20) to VARCHAR(30).



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 05:19:36
Hi peso,now the data getting inserted
report name user id date snoFlash report RAMCOVM392.rsimail.rsil.ramco.com 2008-08-11 14:47:05.730
312

thought it is coming from front end ,its getting saved as server name.i need to save the client machine name or ipaddress

quote:
Originally posted by Peso

Change VARCHAR(20) to VARCHAR(30).



E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-11 : 05:29:52
It is VERY easy to get the CLIENT name (and even the client IP) from the CLIENT application!
Just call the WINDOWS API, and supply the information to the database in your dynamically constructed string.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 05:44:54
hi peso,though it comes from front end application[ERP Product]we can't modify the front end.sp logic alone it is possible to modify.
whether there is any alternative way to do??

quote:
Originally posted by Peso

It is VERY easy to get the CLIENT name (and even the client IP) from the CLIENT application!
Just call the WINDOWS API, and supply the information to the database in your dynamically constructed string.


E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-11 : 05:47:25
The only way to get the SERVERNAME with HOST_NAME() function is when you run the code ON the server itself.
Are you running the Application with CITRIX or similar ON the database server?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-08-11 : 07:05:10
Txs for every one.
quote:
Originally posted by Peso

The only way to get the SERVERNAME with HOST_NAME() function is when you run the code ON the server itself.
Are you running the Application with CITRIX or similar ON the database server?



E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page
    Next Page

- Advertisement -