October 7, 2014 at 8:06 am
How I can change this IP Address
14.192.128.0
To
014.192.128.000
Or how I can parse above IP in 4 Pieces
14.192.128.0
To
14
192
128
0
in SSIS. I know I can use derived column. I need expression help.
Thank You.
October 7, 2014 at 8:59 am
Maybe with this set of formulas and noting that I used the variable @[User::ip] instead of a column:
SUBSTRING( @[User::ip], 1 , FINDSTRING( @[User::ip] , ".", 1 ) - 1)
SUBSTRING( @[User::ip], FINDSTRING( @[User::ip] , ".", 1 ) + 1 , FINDSTRING( @[User::ip] , ".", 2 ) - FINDSTRING( @[User::ip] , ".", 1 ) - 1)
SUBSTRING( @[User::ip], FINDSTRING( @[User::ip] , ".", 2 ) + 1 , FINDSTRING( @[User::ip] , ".", 3 ) - FINDSTRING( @[User::ip] , ".", 2 ) - 1)
SUBSTRING( @[User::ip], FINDSTRING( @[User::ip] , ".", 3 ) + 1 , 3)
October 8, 2014 at 4:05 am
If you want four separate parts :
First Part:
SUBSTRING(IP,1,FINDSTRING(IP,".",1) - 1)
Second Part:
SUBSTRING(IP,FINDSTRING(IP,".",1) + 1,FINDSTRING(IP,".",2) - FINDSTRING(IP,".",1) - 1)
Third Part:
SUBSTRING(IP,FINDSTRING(IP,".",2) + 1,FINDSTRING(IP,".",3) - FINDSTRING(IP,".",2) - 1)
Fourth Part:
SUBSTRING(IP,FINDSTRING(IP,".",3) + 1,LEN(IP) - FINDSTRING(IP,".",3))
If you want the whole string in 3 digit placeholder format:
(LEN(SUBSTRING(IP,1,FINDSTRING(IP,".",1) - 1))==1?"00": (LEN(SUBSTRING(IP,1,FINDSTRING(IP,".",1) - 1))==2?"0":""))+SUBSTRING(IP,1,FINDSTRING(IP,".",1) - 1)
+"."+
(LEN(SUBSTRING(IP,FINDSTRING(IP,".",1) + 1,FINDSTRING(IP,".",2) - FINDSTRING(IP,".",1) - 1))==1?"00": (LEN(SUBSTRING(IP,FINDSTRING(IP,".",1) + 1,FINDSTRING(IP,".",2) - FINDSTRING(IP,".",1) - 1))==2?"0":""))+SUBSTRING(IP,FINDSTRING(IP,".",1) + 1,FINDSTRING(IP,".",2) - FINDSTRING(IP,".",1) - 1)
+"."+
(LEN(SUBSTRING(IP,FINDSTRING(IP,".",2) + 1,FINDSTRING(IP,".",3) - FINDSTRING(IP,".",2) - 1))==1?"00": (LEN(SUBSTRING(IP,FINDSTRING(IP,".",2) + 1,FINDSTRING(IP,".",3) - FINDSTRING(IP,".",2) - 1))==2?"0":""))+SUBSTRING(IP,FINDSTRING(IP,".",2) + 1,FINDSTRING(IP,".",3) - FINDSTRING(IP,".",2) - 1)
+"."+
(LEN(SUBSTRING(IP,FINDSTRING(IP,".",3) + 1,LEN(IP) - FINDSTRING(IP,".",3)))==1?"00": (LEN(SUBSTRING(IP,FINDSTRING(IP,".",3) + 1,LEN(IP) - FINDSTRING(IP,".",3)))==2?"0":""))+SUBSTRING(IP,FINDSTRING(IP,".",3) + 1,LEN(IP) - FINDSTRING(IP,".",3))
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply