DECLARE @IpAddr varchar(15)
SET @IpAddr = '127.0.0.1'
-- #### IPを数字に変更 #### START ####
DECLARE @IpNum numeric(18,0)
DECLARE @ip1 bigint, @ip2 bigint, @ip3 bigint, @ip4 bigint
SET @ip1 = PARSENAME(@IpAddr, 4)
SET @ip2 = PARSENAME(@IpAddr, 3)
SET @ip3 = PARSENAME(@IpAddr, 2)
SET @ip4 = PARSENAME(@IpAddr, 1)
SET @IpNum = @ip1*(256*256*256)+@ip2*(256*256)+@ip3*(256)+@ip4
-- #### IPを数字に変更 #### END ####
-- #### 結果確認 ####
SELECT @IpAddr AS [IpAddress], @IpNum AS [IpAddressNumber]