﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Select just three octets from IP number / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 04:53:23 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Select just three octets from IP number</title><link>http://www.sqlservercentral.com/Forums/Topic525938-338-1.aspx</link><description>This is great information, thanks!</description><pubDate>Thu, 25 Feb 2010 07:04:46 GMT</pubDate><dc:creator>robbaker</dc:creator></item><item><title>RE: Select just three octets from IP number</title><link>http://www.sqlservercentral.com/Forums/Topic525938-338-1.aspx</link><description>Alternatively u can do:DECLARE @t VARCHAR(15)SET @t = '10.0.123.77'SELECT Left(@t,Len(@t)-CHARINDEX('.',Reverse(@t)))</description><pubDate>Mon, 30 Jun 2008 08:32:54 GMT</pubDate><dc:creator>Hari.Sharma</dc:creator></item><item><title>RE: Select just three octets from IP number</title><link>http://www.sqlservercentral.com/Forums/Topic525938-338-1.aspx</link><description>DECLARE @t VARCHAR(15)SET @t = '10.0.123.77'SELECT PARSENAME(@t,4)+'.'+PARSENAME(@t,3)+'.'+PARSENAME(@t,2)</description><pubDate>Mon, 30 Jun 2008 08:29:07 GMT</pubDate><dc:creator>Hari.Sharma</dc:creator></item><item><title>RE: Select just three octets from IP number</title><link>http://www.sqlservercentral.com/Forums/Topic525938-338-1.aspx</link><description>DECLARE @t VARCHAR(15)SET @t = '111.222.333.444'SELECT PARSENAME(@t,4),PARSENAME(@t,3),PARSENAME(@t,2)</description><pubDate>Mon, 30 Jun 2008 08:01:22 GMT</pubDate><dc:creator>Jason Selburg</dc:creator></item><item><title>Select just three octets from IP number</title><link>http://www.sqlservercentral.com/Forums/Topic525938-338-1.aspx</link><description>I need to create a function to select just 3 octets from a column (ip_number).I paste below the select that I did, but it is very large. anyone have any idea so that I can reduce this select?-- I want to identify only three octets, the IP numberdeclare @x varchar(20)select @x = '10.0.42.162'select @x = '10.0.200.120'select @x Ip,substring(@x,1,len(substring(@x,1,charindex('.', @x ))))+substring(substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)),1,len(substring(substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)),1,charindex('.', substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)) )))) +substring(SUBSTRING(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x ))))+substring(substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)),1,len(substring(substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)),1,charindex('.', substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)) )))))+1,LEN(@x)),1,charindex('.', SUBSTRING(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x ))))+substring(substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)),1,len(substring(substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)),1,charindex('.', substring(@x,len(substring(@x,1,len(substring(@x,1,charindex('.', @x )))))+1,len(@x)) )))))+1,LEN(@x)) )) rede</description><pubDate>Mon, 30 Jun 2008 07:57:08 GMT</pubDate><dc:creator>rodrigo.rollo</dc:creator></item></channel></rss>