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
 General SQL Server Forums
 New to SQL Server Programming
 left aligned

Author  Topic 

deeparavi
Starting Member

2 Posts

Posted - 2010-07-13 : 06:42:22
can someone help in writing a sql query to convert a numeric value (right aligned) to alphanumeric value (left aligned)?

e.g. (- means space)

numeric value --------1800 à alphanumeric 1800--------

numeric value ------312206 à alphanumeric 312206------

numeric value --------2206 à alphanumeric 2206--------

deeparavi
Starting Member

2 Posts

Posted - 2010-07-13 : 07:07:31
this is a bit urgent.. someone help!!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-13 : 07:08:35
So your numeric value IS ALREADY hold in a character datatype?

select right(replicate(' ',12)+ltrim(' 1800'),12)



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-07-13 : 07:12:53
SELECT CAST(LTRIM(Col1) AS CHAR(12))



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-16 : 11:44:43
If you use front end application do it there

Madhivanan

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

- Advertisement -