Pregunta

I have some dumps from a Microsoft TMG log table, the IP address is stored as a uniqueidentifier. I was able to convert the values into human-readable "dotted octet notation" (this is all IP v4 stuff), but the values are coming out reversed.

What is the most efficient way to reverse the values?

Thanks.

Examples:

Is                  ShouldBe
189.148.151.123     123.151.148.189
251.116.199.173     173.199.116.251
1.0.0.127           127.0.0.1
¿Fue útil?

Solución

You can (ab)use parsename for that:

select  parsename(ip_col,4) + '.' +
        parsename(ip_col,3) + '.' +
        parsename(ip_col,2) + '.' +
        parsename(ip_col,1)
from    YourTable
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top