Isn't
Select Right(Replicate(' ', 20-LEN(Column_Name)) +Column_Name, 20)
From Table
would be right?
But I run both ways, but did not get desirable result.
Data type in this field is char(13), but it's actualy decimal and represent Amount
When I open table in SQL Server EM my data in this column is still in the middle and not alighed
Running a SELECT query doesn't change the data in the table. It only displays the data right justified in the result set of SELECT. Do you want to update the table? If so use an UPDATE query.
Update Table_name
Set column_name=replicate(' ',13-len(column_name)) + column_name
To zero fill replicate '0' rather than ' '. Terry L. Broadbent - DBA
SQL Server Page:
I used this syntax only for example and modified your example. I create new table with "SELECT INTO" . It should create table with right justified field. if syntax is correct.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.