Kaela.
Kaela.

Reputation: 11

How to change IP Address to other format?

I need to include client's IP Address in signature code, by using this code to get client's IP Address:

SELECT  client_net_address as IPAdd
FROM    sys.dm_exec_connections
WHERE   session_id = @@SPID

I can now get the IP Address as:

Ex: 192.168.1.24

How can i reformat it to something like this:

192168001024

I know we can do something like this in C# by using Split, PadLeft and Concat. But is it possible to do it in SQL Server too?

Thank You.

Upvotes: 1

Views: 70

Answers (1)

Ravindra Puli
Ravindra Puli

Reputation: 11

You have to write a function and can call from the query, there is no direct method to convert such notation transformation.

Upvotes: 1

Related Questions