T-sql Remove Zero Padding As String Manipulation October 27, 2023 Post a Comment If you are dealing with strings as nvarchar and varchar in SQL Server what is the correct way to drop leading zeros without casting to an INT type? Say '000123' for example. I woulSolution 1: DECLARE@VarVARCHAR(100) ='000000658410065446'SELECTSUBSTRING(@Var, PATINDEX('%[^0]%',@Var), 100) CopyOR SELECTSUBSTRING(@Var, PATINDEX('%[^0]%',@Var), LEN(@Var)- PATINDEX('%[^0]%',@Var)+ 1) CopyBoth will return the same Result as followsResult658410065446 Copy Share Post a Comment for "T-sql Remove Zero Padding As String Manipulation"
Post a Comment for "T-sql Remove Zero Padding As String Manipulation"