In the Results Pane, Display decimal field value with right alignment:
I have one table called EmployeeSalary with two columns EmpID(int) and Salary(decimal(15,2))
While selecting the Table, The Results in the Results Pane is like below:
SELECT * FROM EmployeeSalary
EmpID Salary
------ --------
开发者_StackOverflow 1 5000.00
2 12000.00
But I want to display the salary with right alignment like below;
EmpID Salary
------ --------
1 5000.00
2 12000.00
How to do this?
This should provide your answer...
http://msdn.microsoft.com/en-us/library/ms178782(v=SQL.90).aspx
Query->Query Options->Results->Text->Right Align Numeric Values
DECLARE @MaxLength DECIMAL(18,2)
SELECT @MaxLength = MAX(LEN(Salary)) FROM EmployeeSalary
SELECT LEN(Salary), REPLICATE(' ', @MaxLength - LEN(Salary))+ CAST(Salary AS VARCHAR) FROM EmployeeSalary
精彩评论