Skip to content

Instantly share code, notes, and snippets.

@h3nryza
Created July 17, 2018 17:19
Show Gist options
  • Save h3nryza/0c895dfeb1d14a47f5b3924c23b9863f to your computer and use it in GitHub Desktop.
Save h3nryza/0c895dfeb1d14a47f5b3924c23b9863f to your computer and use it in GitHub Desktop.
Substring of IP Address in Sql
SQL Calculate IP Subnet
(charindex ( '.' , CMP.IPAddress ,charindex( '.' , CMP.IPAddress ,(charindex('.',CMP.IPAddress) +1 ) ) +1)-1)
SQL Spit out SQL Subnet
SUBSTRING(
CMP.IPAddress,
0,
(charindex ( '.' , CMP.IPAddress ,charindex( '.' , CMP.IPAddress ,(charindex('.',CMP.IPAddress) +1 ) ) +1))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment