sql server remove 0 from left 1

sql server remove 0 from left

  SUBSTRING(str_col, PATINDEX('%[^0]%', str_col+'.'), LEN(str_col))

Here is what the above code is Doing:
1. The first PATINDEX() function is looking for the first non-zero character in the string.
2. The second PATINDEX() function is looking for the first non-zero character after the first non-zero character.
3. The SUBSTRING() function is then used to extract the characters between the two PATINDEX() functions.

Similar Posts