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
------ --------
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?
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