Question

  Asked: May 27 2008   12:36 AM GMT
  Asked by: Red


Numeric Field to be left aligned


Database programming

I have declared a numeric field with lenth 15,2, the same to be displayed left aligned. By default it is displaying right aligned.

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



Hi,

You could "move left" the field into a character field (MOVEL) in RPG or right trim RTRIM in SQL

Regards,

Martin Gilbert.

The SQL Server is self doesn't provide a way to do this. You'll need to handle this alignment with the client application which is displaying the data. Most client development tools have a way to align the data to the left within the textbox or field.


Or, convert it to a string with a scalar function on SQL server.
SELECT CAST(price AS VARCHAR)
Once converted it will align left.
Note that you might need to give it a name using the AS keyword if it displays under a weird column heading.
SELECT CAST(price AS VARCHAR) AS "Price_"
An issue remains: how will SQL Server edit the number? I didn't find a function for this purpose.
--
Juan Lanus
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Development.

Looking for relevant Development Whitepapers? Visit the SearchWinDevelopment.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register