Numeric Field to be left aligned

5 pts.
Tags:
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.

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following