Hello everybody,
we got data from a dns server that looks like:
some colums.... |121.12.250.2.somestring......|
The ip adress should look like 2.250.12.121:
We could use charindex, substring and len to cut the 4 parts of the ip
and rebuild it in the right format.
Starts with
SELECT
CHARINDEX('.',mycolumn)
,LEFT(mycolumn, CHARINDEX('.',mycolumn) - 1) as part_four_of_ip
,CHARINDEX('.', SUBSTRING(mycolumn,CHARINDEX('.',mycolumn) - 1),len(mycolumn)
as position_of_second_dot
........ and so on.....
This will cause an awful long code.
Any ideas how to shorten that code?
best regards
Michael
we got data from a dns server that looks like:
some colums.... |121.12.250.2.somestring......|
The ip adress should look like 2.250.12.121:
We could use charindex, substring and len to cut the 4 parts of the ip
and rebuild it in the right format.
Starts with
SELECT
CHARINDEX('.',mycolumn)
,LEFT(mycolumn, CHARINDEX('.',mycolumn) - 1) as part_four_of_ip
,CHARINDEX('.', SUBSTRING(mycolumn,CHARINDEX('.',mycolumn) - 1),len(mycolumn)
as position_of_second_dot
........ and so on.....
This will cause an awful long code.
Any ideas how to shorten that code?
best regards
Michael