Sometimes we need to remove the leading zeros from number which has no value . Lets consider the example we are generating Id's like 000012 , In this number 12 is actual value where 0 has no value at all. So while displaying number we wants to remove the leading zeros then following code snippet is very useful to perform these types of task.
- Select SUBSTRING('0000256', PATINDEX('%[^0]%', '0000256'+'.'), LEN('0000256')) as EmpId
OutPut:
256