Skip to content Skip to sidebar Skip to footer

Remove Zero In A Column

I have created a table with a column of type nvarchar(max): CREATE TABLE Table1 (Col1 nvarchar(max)) INSERT table1 values('A001') INSERT table1 values('A005') INSERT table1 values

Solution 1:

You Can try Like this,,,

SelectLEFT(Col1, 1)+Cast(CAST(Replace(Col1,'A','') asInt) as nvarchar(Max)) as Col1 from Table1

SQL Fiddle Demo

Solution 2:

selectleft(Col1,1)+ltrim(convert(int,substring(Col1,2,99)))

Solution 3:

You can try it using Replace()

Select REPLACE(Col1,'0','') as Col1 from Table1;

Post a Comment for "Remove Zero In A Column"