Remove or trim the leading zeros in SQL

Some times we need to remove or trim the leading zeros in an alphanumeric column of a table flied. Following SQL query will help us to  do this.

DECLARE @String nvarchar(100)

SET @String='000123050'

SELECT SUBSTRING(@String,PATINDEX('%[1-9]%', @String),LEN(@String))

After run the above query you will get the output: 123050
Remember that the orginal string was: 000123050


  1. By Rayhan


Leave a Reply

Your email address will not be published. Required fields are marked *