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.
Author |
Topic |
HelalM
Starting Member
19 Posts |
Posted - 2012-10-17 : 19:22:52
|
My data in column A look like:-000200030-000400050I need to remove the first character '-' when occurs and then add a trailing zero so result is:00020000300004000050Thank You for your helpHM |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2012-10-17 : 19:33:36
|
[CODE]select case when left(ColA, 1) = '-' then right(ColA, len(ColA) - 1) + '0' else ColA end ColAfrom MyTable[/CODE]=================================================We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-17 : 23:09:18
|
SELECT LEFT(REPLACE(field,'-','')+'0',5) FROM tableif there are no other - characters------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
HelalM
Starting Member
19 Posts |
Posted - 2012-10-18 : 13:32:43
|
Awesome...thank youHM |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-18 : 14:07:27
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|