What the hell are you doing up at 6:20am on a Saturday morning? You *must*
be a geek! Oh, wait...
t
http://www.ISAserver.org
Many great apologies, he who is called "Tim"... I had no idea you were SQLiterate.
..much thankling you are I.
-----Original Message----- From: Thor (Hammer of God) [mailto:thor@xxxxxxxxxxxxxxx] Sent: Friday, May 06, 2005 5:25 PM To: [ISAserver.org Discussion List] Subject: [isalist] Re: long_2_ipaddr.js.txt
http://www.ISAserver.org
What am I, chopped liver?
snip>declare @int as bigint, @bin varbinary(4), @ip varchar(15)
select @int = 1023508566 -- or however you're grabbing the data. select @bin = cast(@int as varbinary(4))
select @ip = cast(convert(int,substring(@bin,1,1)) as varchar(3)) + '.' + cast(convert(int,substring(@bin,2,1)) as varchar(3)) + '.' + cast(convert(int,substring(@bin,3,1)) as varchar(3)) + '.' + cast(convert(int,substring(@bin,4,1)) as varchar(3))
select @ip
</snip>
T
----- Original Message ----- From: "Jim Harrison" <Jim@xxxxxxxxxxxx>
To: "[ISAserver.org Discussion List]" <isalist@xxxxxxxxxxxxx>
Sent: Friday, May 06, 2005 4:00 PM
Subject: [isalist] long_2_ipaddr.js.txt
belowhttp://www.ISAserver.org
Hi Joe!
Oh, great SQL deity, how would a lowly scripter transmorgrify theJscript function to T-SQL? What it does is translate a long (SQL BigInt) to an IP address string. Save it as 'long2string.js' Run it as 'cscript long2string.js 1023508566'.
<snip> var lIpAddr = parseInt( WScript.Arguments( 0 ) );
WScript.Echo( "IP_long " + lIpAddr + " == IP_String \'" + IpLongToIpString( lIpAddr ) + "\'." );
function IpLongToIpString( lIpAddr ) { var arrIPAddr = new Array( ); var iOctetMask = 0xFF; var iNumBits = 8; for( var iOctetCtr = 3; iOctetCtr >= 0; iOctetCtr-- ) { var iOctet = ( lIpAddr >>> ( iNumBits * iOctetCtr ) ) & iOctetMask; arrIPAddr.push( iOctet ); } return arrIPAddr.join( "." ); } </snip>
I need to do this in a view so that my OLAP cube presents it in a "readable" form. T'anx!
------------------------------------------------------- Jim Harrison MCP(NT4, W2K), A+, Network+, PCG http://isaserver.org/Jim_Harrison/ http://isatools.org Read the help / books / articles! -------------------------------------------------------
All mail to and from this domain is GFI-scanned.
------------------------------------------------------ List Archives: http://www.webelists.com/cgi/lyris.pl?enter=isalist ISA Server Newsletter: http://www.isaserver.org/pages/newsletter.asp ISA Server FAQ: http://www.isaserver.org/pages/larticle.asp?type=FAQ ------------------------------------------------------ Other Internet Software Marketing Sites: World of Windows Networking: http://www.windowsnetworking.com Leading Network Software Directory: http://www.serverfiles.com No.1 Exchange Server Resource Site: http://www.msexchange.org Windows Security Resource Site: http://www.windowsecurity.com/ Network Security Library: http://www.secinf.net/ Windows 2000/NT Fax Solutions: http://www.ntfaxfaq.com ------------------------------------------------------ You are currently subscribed to this ISAserver.org Discussion List as:
http://www.webelists.com/cgi/lyris.pl?enter=isalistthor@xxxxxxxxxxxxxxx To unsubscribe visitReport abuse to listadmin@xxxxxxxxxxxxx
------------------------------------------------------ List Archives: http://www.webelists.com/cgi/lyris.pl?enter=isalist ISA Server Newsletter: http://www.isaserver.org/pages/newsletter.asp ISA Server FAQ: http://www.isaserver.org/pages/larticle.asp?type=FAQ ------------------------------------------------------ Other Internet Software Marketing Sites: World of Windows Networking: http://www.windowsnetworking.com Leading Network Software Directory: http://www.serverfiles.com No.1 Exchange Server Resource Site: http://www.msexchange.org Windows Security Resource Site: http://www.windowsecurity.com/ Network Security Library: http://www.secinf.net/ Windows 2000/NT Fax Solutions: http://www.ntfaxfaq.com ------------------------------------------------------ You are currently subscribed to this ISAserver.org Discussion List as: jim@xxxxxxxxxxxx To unsubscribe visit http://www.webelists.com/cgi/lyris.pl?enter=isalist Report abuse to listadmin@xxxxxxxxxxxxx
All mail to and from this domain is GFI-scanned.
------------------------------------------------------
List Archives: http://www.webelists.com/cgi/lyris.pl?enter=isalist
ISA Server Newsletter: http://www.isaserver.org/pages/newsletter.asp
ISA Server FAQ: http://www.isaserver.org/pages/larticle.asp?type=FAQ
------------------------------------------------------
Other Internet Software Marketing Sites:
World of Windows Networking: http://www.windowsnetworking.com
Leading Network Software Directory: http://www.serverfiles.com
No.1 Exchange Server Resource Site: http://www.msexchange.org
Windows Security Resource Site: http://www.windowsecurity.com/
Network Security Library: http://www.secinf.net/
Windows 2000/NT Fax Solutions: http://www.ntfaxfaq.com
------------------------------------------------------
You are currently subscribed to this ISAserver.org Discussion List as: thor@xxxxxxxxxxxxxxx
To unsubscribe visit http://www.webelists.com/cgi/lyris.pl?enter=isalist
Report abuse to listadmin@xxxxxxxxxxxxx