To customize it you need to replace the ~ with a char that is not used in your column.
See my code below:
Copyable Version:
CREATE Table [dbo].[Leading_Zeros](
[INT] [bigint] NULL,
[Varchar] [varchar](250) NULL
) ON [PRIMARY]
GO
INSERT INTO [Leading_Zeros]
Values (1, '001'),
(2, 'Zero0000Zero'),
(3, '156000748465'),
(4, '000555000555000'),
(5, 'TestString'),
(6, 'Test00000String')
select *,
REPLACE(REPLACE(LTRIM(REPLACE(REPLACE([Varchar], ' ', '~'), '0', ' ')), ' ', '0'), '~', ' ') Leading_Zeros
from [Leading_Zeros]
No comments:
Post a Comment