Loading ...

Remove leading zeroes from numbers | CodeAsp.Net

Remove leading zeroes from numbers

 /5
0 (0votes)

In this blog I will explain how to remove leading zeros from numbers. Below is the script :

GO

CREATE TABLE [TESTTABLE]

([ID] NVARCHAR(50))

GO

INSERT INTO [TESTTABLE] VALUES('000001')

INSERT INTO [TESTTABLE] VALUES('000002')

INSERT INTO [TESTTABLE] VALUES('000003')

INSERT INTO [TESTTABLE] VALUES('000004')

GO

SELECT REPLACE(LTRIM(REPLACE([ID],'0',' ')),' ','0') AS [COLUMN]

FROM [TESTTABLE]

--OUTPUT

COLUMN

--------------------

1

2

3

4

GO

 

Happy Reading!

 

Comments (no comments yet)

Top Posts