I have a column called IP with data such as 10.001.99.108
I want to run a script to change it to look like 10.1.99.108
I have used this before:
update TABLE set IP = substring(IP, patindex('%[^0]%',IP), 10)
but that removes leading zeros at the begging.
Im not sure how I could change it to do the second segment.
You can do this with
parsename()
and a method to remove the leading zeros. The following removes the leading zeros by casting to an integer and then back to string:try this solution
output result