﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Strategies  / How to insert IP Address in data table dynamically / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 16:06:00 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How to insert IP Address in data table dynamically</title><link>http://www.sqlservercentral.com/Forums/Topic959945-361-1.aspx</link><description>ipconfig will return information about the SERVER's NIC card...it would not have any information about the connecting users. that code might seem to work if your SQL server is also your development platform....if they are different, it would obviously not be accurate.one of the data managment views (DMV) as the column sys.dm_exec_connections which is the connecting user's IP address; I'm not sure if you can use it in an logon audit trigger, I'd have to test that, but you can certainly use it inside a stored procedure or other statement after they've connected.[code]select   host_name(),  app_name(),  client_net_address from sys.dm_exec_connections where session_id = @@spid[/code]</description><pubDate>Wed, 28 Jul 2010 06:45:49 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>How to insert IP Address in data table dynamically</title><link>http://www.sqlservercentral.com/Forums/Topic959945-361-1.aspx</link><description>i have a store procedure for user login which i am calling in my ASP.NET code.And now i want that when user log, the IP Address of that user's system and date time of system will get saved into another table.i should be saved in 192.167.1.78 format. i have gone through your article but thats not fullfiling my need.please help me how can i do this.i tried this code which is not working. one thing i m not understanding as i am not very usuall with store procedure coding.what does [u][b]exec dbo.xp_cmdshell'ipconfig'[/b][/u] stand for.i mean what is "xp_cmdshell" and which dbo it is executing.My code is:ALTER PROCEDURE [dbo].[User_Login]@username varchar(20),@pword nvarchar(15),@ipadress varchar(40) output,@RS int outputASSELECT @RS = COUNT(*) FROM Users WHERE username=@username AND pword=@pwordBEGINDECLARE @ipLine varchar(200)DECLARE @pos int SET NOCOUNT ONSET @ipaddress = NULLCREATE TABLE LoginDetail(ipLine varchar(200))INSERT INTO LoginDetail exec dbo.xp_cmdshell'ipconfig'SELECT @ipLine = ipLine FROM LoginDeatil WHERE upper (ipLine) LIKE '%IP ADDRESS%'IF (ISNULL (@ipLine,'***') != '***')BEGIN SET @pos = CharIndex(':',@ipLine,1);SET @ipaddress = RTRIM(LTRIM(SUBSTRING (@ipLIne,@pos + 1,LEN(@ipLine)-@pos)))ENDDROP TABLE LoginDeatinSET NOCOUNT OFFENDGOi have to call this SP in my ASP.NET code.i dont want to display ip address and date time in front end.Only want to store ip and date time.</description><pubDate>Wed, 28 Jul 2010 05:15:50 GMT</pubDate><dc:creator>anamika.singh282</dc:creator></item></channel></rss>