开发者

In the Results Pane, Display decimal field value with right alignment:

开发者 https://www.devze.com 2023-03-26 16:05 出处:网络
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:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号