ASP.NET,C#.NET,VB.NET,JQuery,JavaScript,Gridview,SQL Server,Ajax,jQuery Plugins,jQuery UI,SSRS,XML,HTML,jQuery demos,code snippet examples.

Breaking News

  1. Home
  2. sql
  3. Remove or trim the leading zeros in SQL

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))
Output
After run the above query you will get the output: 123050
Remember that the orginal string was: 000123050

No comments