What I am trying to do here is get a list of clients with their IP address but SQL IP is in decimal encoded format. Running the below query is returning errors. How can I modify the query to run as one and to make it return IP address instead of decimal format?
select distinct(clientusername), clientip,
from weblog
where logtime > '2013-03-01'
UNION
SELECT
CAST(ClientIP / 256 / 256 / 256 % 256 AS VARCHAR) + '.' +
CAST(ClientIP / 256 / 256 % 256 AS VARCHAR) + '.' +
CAST(ClientIP / 256 % 256 AS VARCHAR) + '.' +
CAST(ClientIP % 256 AS VARCHAR)
AS [Nice Source Ip], WebLog.*
From WebLog