DECLARE @ip VARCHAR(15)='128.2.54.123'
SELECT @ip=REVERSE(@ip)
SELECT @ip=SUBSTRING(@ip,CHARINDEX('.',@ip),LEN(@ip))
SELECT @ip=REVERSE('*'+@IP)
SELECT @IP
DECLARE @op VARCHAR(15)='128.2.54.123'
SELECT REVERSE('*'+SUBSTRING(REVERSE(@op),CHARINDEX('.',REVERSE(@op)),LEN(@op)))
if object_id('tempdb..#')is not null drop table #
go
create table #(ip varchar(20))
insert # select '192.168.12.1'
insert # select '192.16.12.101'
insert # select '192.168.12.10'
select stuff(ip,charindex('.',ip,charindex('.',ip,charindex('.',ip)+1)+1)+1,len(ip)-charindex('.',ip,charindex('.',ip,charindex('.',ip)+1)+1),'***') from #