Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 T SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-07-10 : 09:16:40
sa writes "what SQL should i write to right pad ZERO's from my list. Output of my table

00123304050
01203040404
00002334400
12133300933

required output

123304050
1203040404
2334400
12133300933


It should only suppress Zero's on the left


Thanks in advance"

nr
SQLTeam MVY

12543 Posts

Posted - 2006-07-10 : 09:20:09
select convert(varchar(20),convert(int,col))
from tbl

select case when left(col,1) = '0' then right(col,len(col) - patindex('%[^0]%',col + 1) else col end
from tbl

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-07-10 : 09:20:30
If your table contains just numeric data, you can try following:

select convert(int,convert(varchar(30), col1)) from sometable


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-10 : 09:22:44
If you use front end application, do formation there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -